Anonymous user
Doubly-linked list/Definition: Difference between revisions
→{{header|D}}
Line 600:
=={{header|D}}==
<lang d>
class LinkedList(T)
{
Node!(T) head, tail;
/** Iterate in the forward direction. */
int opApply (int delegate(uint, Node!(T)) dg)
Line 619 ⟶ 621:
return result;
}
static LinkedList!(T) fromArray (T[] array)
{
Line 641 ⟶ 643:
LinkedList!(T) parent;
T value;
this (Node!(T) next, Node!(T) previous, T value, LinkedList!(T) parent)
in
Line 657 ⟶ 659:
this.value = value;
this.parent = parent;
if (parent.head == next)
parent.head = this;
Line 663 ⟶ 665:
parent.tail = this;
}
/** Insert an element after this one. */
void insertAfter (T value)
{
new Node!(T)(
}
/** Insert an element before this one. */
void insertBefore (T value)
{
new Node!(T)(
}
/** Remove the current node from the list. */
void remove ()
Line 692 ⟶ 694:
void main ()
{
auto list = LinkedList!
for (auto elem = list.head; elem; elem = elem.next)
{
|