-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlist.h.skel
69 lines (53 loc) · 1.74 KB
/
dlist.h.skel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// copy this file to "dlist.h" and then modify it where specified below
#ifndef __DLIST_H__
#define __DLIST_H__
#include <cstddef>
#include <cassert>
/***************************************
* Do not modify the class declarations!
***************************************/
template <typename T>
class Dlist {
//OVERVIEW: a doubly-linked list
public:
//EFFECTS: returns true if the list is empty
bool isEmpty() const;
//MODIFIES: this
//EFFECTS: inserts v into the front of the list
void insertFront(const T &datum);
//MODIFIES: this
//EFFECTS: inserts v into the back of the list
void insertBack(const T &datum);
//REQUIRES: list is not empty
//MODIFIES: this
//EFFECTS: removes the item at the front of the list
T removeFront();
//REQUIRES: list is not empty
//MODIFIES: this
//EFFECTS: removes the item at the back of the list
T removeBack();
Dlist(); // ctor
Dlist(const Dlist &l); // copy ctor
Dlist &operator=(const Dlist &l); // assignment
~Dlist(); // dtor
private:
struct Node { // A private type
Node *next;
Node *prev;
T datum;
};
Node *first; // The pointer to the first node (0 if none)
Node *last; // The pointer to the last node (0 if none)
//MODIFIES: this
//EFFECTS: copies all nodes from l to this
void copyAll(const Dlist &l);
//MODIFIES: this
//EFFECTS: removes all nodes
void removeAll();
};
/**** DO NOT MODIFY ABOVE THIS LINE *****/
/***************************************
* Member function implementations here
***************************************/
/* this must be at the end of the file */
#endif /* __DLIST_H__ */