DList

Doubly-linked list.

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

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

Constructors

this
this(T[R] init, Allocator allocator)

Creates a new $(D_PSYMBOL DList) with the elements from a static array.

this
this(R init, Allocator allocator)

Creates a new $(D_PSYMBOL DList) with the elements from an input range.

this
this(size_t len, T init, Allocator allocator)
this(size_t len, Allocator allocator)
this(Allocator allocator)

Creates a new $(D_PSYMBOL DList).

this
this(R init, Allocator allocator)

Initializes this list from another one.

Destructor

~this
~this()

Removes all elements from the list.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

ConstRange
alias ConstRange = DRange!(const DList)

The range types for $(D_PSYMBOL DList).

Range
alias Range = DRange!DList

The range types for $(D_PSYMBOL DList).

insert
alias insert = insertBack

Inserts a new element at the end.

Functions

clear
void clear()

Removes all contents from the list.

insertAfter
size_t insertAfter(Range r, R el)
size_t insertAfter(Range r, T el)

Inserts new elements after r.

insertAfter
size_t insertAfter(Range r, T[R] el)

Inserts elements from a static array after r.

insertBack
size_t insertBack(R el)
size_t insertBack(T[R] el)

Inserts a new element at the end.

insertBefore
size_t insertBefore(Range r, R el)
size_t insertBefore(Range r, T el)

Inserts new elements before r.

insertBefore
size_t insertBefore(Range r, T[R] el)

Inserts elements from a static array before r.

insertFront
size_t insertFront(R el)
size_t insertFront(T[R] el)

Inserts a new element at the beginning.

opAssign
typeof(this) opAssign(R that)

Assigns another list.

opAssign
typeof(this) opAssign(R that)

Assigns an input range.

opAssign
typeof(this) opAssign(T[R] that)

Assigns a static array.

opEquals
bool opEquals(typeof(this) that)

Comparison for equality.

opIndex
Range opIndex()
ConstRange opIndex()
popFirstOf
Range popFirstOf(Range range)
popLastOf
Range popLastOf(Range range)

Removes the front or back element of the range from the list respectively.

remove
Range remove(Range r)

Removes r from the list.

removeBack
void removeBack()

Removes the front or back element.

removeBack
size_t removeBack(size_t howMany)

Removes howMany elements from the list.

removeFront
void removeFront()

Removes the front or back element.

removeFront
size_t removeFront(size_t howMany)

Removes howMany elements from the list.

Mixins

__anonymous
mixin DefaultAllocator
Undocumented in source.

Properties

back
inout(T) back [@property getter]
empty
bool empty [@property getter]
front
inout(T) front [@property getter]

Mixed In Members

From mixin DefaultAllocator

allocator_
Allocator allocator_;

Allocator.

this
this(Allocator allocator)
allocator
shared(Allocator) allocator [@property getter]

This property checks if the allocator was set in the constructor and sets it to the default one, if not.

Parameters

T

Content type.

Examples

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);

Meta