LinkedList

Undocumented in source.

Constructors

this
this(AllocatorWrapperOf!AllocT alloc)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

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

Members

Aliases

getAt
alias getAt = getAtHead
Undocumented in source.
put
alias put = putTail
Undocumented in source.
removeAt
alias removeAt = removeAtHead
Undocumented in source.

Functions

getAtHead
inout(T) getAtHead(size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.
insertAt
void insertAt(size_t index, T value)
Undocumented in source. Be warned that the author may not have intended to support it.
moveTail
void moveTail(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
opDollar
size_t opDollar()
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
inout(T) opIndex(size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.
putHead
void putHead(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
putTail
void putTail(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
putTail
void putTail(Args args)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAtHead
void removeAtHead(size_t index, T dest)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAtHead
T removeAtHead(size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAtTail
void removeAtTail(size_t index, T dest)
Undocumented in source. Be warned that the author may not have intended to support it.
removeAtTail
T removeAtTail(size_t index)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

length
size_t length [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
range
auto range [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Node
struct Node
Undocumented in source.

Examples

1 import libd.algorithm : isCollection, isInputRange;
2 import libd.memory    : emplaceInit;
3 static assert(isCollection!(LinkedList!int, int));
4 static assert(isInputRange!(typeof(LinkedList!int.range())));
5 
6 LinkedList!int list;
7 
8 list.put(2);
9 assert(list.length == 1);
10 assert(list._head is list._tail);
11 assert(list.getAt(0) == 2);
12 list.put(4);
13 assert(list.length == 2);
14 assert(list._head !is list._tail);
15 assert(list.getAt(0) == 2);
16 assert(list.getAt(1) == 4);
17 list.putHead(0);
18 assert(list.length == 3);
19 assert(list.getAt(0) == 0);
20 assert(list.getAt(1) == 2);
21 assert(list.getAt(2) == 4);
22 list.getAt(1) /= 2;
23 assert(list.getAt(1) == 1);
24 list.removeAt(1);
25 assert(list.length == 2);
26 assert(list.getAt(0) == 0);
27 assert(list.getAt(1) == 4);
28 list.removeAt(0);
29 assert(list.length == 1);
30 assert(list.getAt(0) == 4);
31 assert(list.removeAt(0));
32 assert(list.length == 0);
33 assert(list._head is list._tail);
34 assert(list._head is null);
35 list.put(0);
36 list.put(0);
37 list.put(0);
38 
39 int next = 2;
40 foreach(ref num; list.range)
41 {
42     num = next;
43     next += 2;
44 }
45 assert(list[0] == 2);
46 assert(list[1] == 4);
47 assert(list[2] == 6);
48 
49 emplaceInit(list);
50 list.insertAt(0, 2); // 2
51 list.insertAt(0, 0); // 0 2
52 list.insertAt(2, 3); // 0 2 3
53 list.insertAt(1, 1); // 0 1 2 3
54 assert(list.length == 4);
55 assert(list[0] == 0);
56 assert(list[1] == 1);
57 assert(list[2] == 2);
58 assert(list[3] == 3);
59 assert(list.removeAtTail(1) == 1);
60 assert(list.removeAtTail(1) == 2);
61 assert(list.removeAtTail(0) == 0);
62 assert(list.removeAtTail(0) == 3);

Meta