-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDLList.cpp
More file actions
36 lines (33 loc) · 695 Bytes
/
Copy pathDLList.cpp
File metadata and controls
36 lines (33 loc) · 695 Bytes
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
//Insert "it" at current position
void insert(const E& it)
{
curr->next = curr->next->prev =
new Link<E>(it, curr, curr->next);
cnt++;
}
//append "it" to the end of the list
void append(const E& it)
{
tail->prev = tail->prev->next =
new Link<E>(it,tail->prev,tail);
cnt++;
}
//remove and return current element
E remove()
{
if (curr->next == tail)
return NULL;
E it = curr->next->element;
Link<E>* ltemp = curr->next;
curr->next->next=>prev = curr;
curr->next = curr->next->next;
delete ltemp;
cnt--;
return it;
}
//move fence one step left; no change if left is empty
void prev()
{
if (curr != head)
curr = curr->prev;
}