Struct DList

Doubly-linked list.

struct DList(T) ;

DList can be also used as a queue. Elements can be enqueued with DList.insertBack. To process the queue a for-loop comes in handy:

for (; !dlist.empty; dlist.removeFront())
{
 do_something_with(dlist.front);
}

Constructors

NameDescription
this Creates a new DList with the elements from a static array.
this Creates a new DList with the elements from an input range.
this Creates a new DList.
this Initializes this list from another one.

Properties

NameTypeDescription
back[get] inout(T)
empty[get] bool
front[get] inout(T)

Methods

NameDescription
clear Removes all contents from the list.
insertAfter Inserts new elements after r.
insertAfter Inserts elements from a static array after r.
insertBack Inserts a new element at the end.
insertBefore Inserts new elements before r.
insertBefore Inserts elements from a static array before r.
insertFront Inserts a new element at the beginning.
opAssign Assigns another list.
opAssign Assigns an input range.
opAssign Assigns another list.
opAssign Assigns a static array.
opEquals Comparison for equality.
opIndex
popFirstOf Removes the front or back element of the range from the list respectively.
popLastOf Removes the front or back element of the range from the list respectively.
remove Removes r from the list.
removeBack Removes the front or back element.
removeBack Removes howMany elements from the list.
removeFront Removes the front or back element.
removeFront Removes howMany elements from the list.

Aliases

NameDescription
ConstRange The range types for DList.
insert Inserts a new element at the end.
Range The range types for DList.

Parameters

NameDescription
T Content type.

Example

DList!int l;
size_t i;

l.insertFront(5);
l.insertFront(4);
l.insertFront(9);
foreach (e; l)
{
    assert(i != 0 || e == 9);
    assert(i != 1 || e == 4);
    assert(i != 2 || e == 5);
    ++i;
}
assert(i == 3);