SLLists provide pseudo-generic singly linked lists. DLLists provide doubly linked lists. The lists are designed for the simple maintenance of elements in a linked structure, and do not provide the more extensive operations (or node-sharing) of class List
. They behave similarly to the slist
and similar classes described by Stroustrup.
All list nodes are created dynamically. Assignment is performed via copying.
Class DLList
supports all SLList
operations, plus additional operations described below.
For purposes of illustration, assume the specification of class intSLList
. In addition to the operations listed here, SLLists support traversal via Pixes. See Pix
intSLList a;
intSLList b = a;
a.empty()
a.length();
a.prepend(x);
a.append(x);
a.join(b)
x = a.front()
a.rear()
x = a.remove_front()
a.del_front()
a.clear()
a.ins_after(Pix i, item);
a.del_after(Pix i);
Class DLList
supports the following additional operations, as well as backward traversal via Pixes.
x = a.remove_rear();
a.del_rear();
a.ins_before(Pix i, x)
a.del(Pix& iint dir = 1)