DoublyLinkedList
object has three data members:
int size
- Number of elements in the list.
DoublyLinkedListNode* head
- Pointer to the first node.
DoublyLinkedListNode* tail
- Pointer to the last node.
DoublyLinkedListNode
has three data members:
T data
- Value stored in the node.
DoublyLinkedListNode* prev
- Pointer to the previous node.
DoublyLinkedListNode* next
- Pointer to the next node.
size >= 0
.
size == 0
, then head == NULL
and tail == NULL
.
size >= 1
, then head != NULL
and
tail != NULL
.
size == 1
, then head == tail
.
size >= 1
, then
next
pointer in node size
is NULL
.
prev
pointer in node 1
is NULL
.
size >= 2
, then
i
from 1
to size - 1
,
the next
pointer in node i
is not NULL
.
i
from 2
to size
, the
prev
pointer in node i
is not NULL
.
prev
pointer of node 2
equals head
.
next
pointer of node size - 1
equals
tail
size >= 3
, then
i
from 2
to size - 1
,
the next
pointer of node i - 1
equals the
prev
pointer of node i + 1
.
doublylinkedlist.h
(original),
doublylinkedlist.h
(copy),
doublylinkedlistnode.h
(original),
doublylinkedlistnode.h
(copy),
ListTest.cpp
.
This page was last modified on Feb 28, 2001
URL: http://people.hsc.edu/faculty-staff/robbk/Coms262/Lectures/DoublyLinkedLists.html