CircularList

Circular linked list

Iterator iterator ()
int opApply (scope int delegate(ref V value) dg)

CircularList add (V element)
CircularList addAt (size_t index, V element)
CircularList append (V element)
CircularList prepend (V element)
size_t addAt (size_t index, IContainer!(V) e)
size_t append (IContainer!(V) e)
size_t prepend (IContainer!(V) e)

bool take (ref V v)
bool contains (V element)
V get (size_t index)
size_t first (V element, size_t startingIndex = 0)
size_t last (V element, size_t startingIndex = 0)

V head ()
V tail ()
V head (V element)
V tail (V element)
V removeHead ()
V removeTail ()

bool removeAt (size_t index)
size_t remove (V element, bool all)
size_t removeRange (size_t fromIndex, size_t toIndex)

size_t replace (V oldElement, V newElement, bool all)
bool replaceAt (size_t index, V element)

size_t size ()
bool isEmpty ()
V[] toArray (V[] dst)
CircularList dup ()
CircularList subset (size_t from, size_t length)
CircularList clear ()
CircularList reset ()
CircularList check ()

Constructors

this
this()

Make an empty list

this
this(Ref h, size_t c)

Make an configured list

Destructor

~this
~this()

Clean up when deleted

Members

Aliases

Type
alias Type = Clink!(V)
Undocumented in source.

Functions

add
CircularList add(V element)

Time complexity: O(1)

addAt
CircularList addAt(size_t index, V element)

Time complexity: O(n)

addAt
size_t addAt(size_t index, IContainer!(V) e)

Time complexity: O(size() + number of elements in e)

append
CircularList append(V element)

Time complexity: O(1)

append
size_t append(IContainer!(V) e)

Time complexity: O(number of elements in e)

cache
CircularList cache(size_t chunk, size_t count)

Configure the assigned allocator with the size of each allocation block (number of nodes allocated at one time) and the number of nodes to pre-populate the cache with.

check
CircularList check()
clear
CircularList clear()

Time complexity: O(1)

contains
bool contains(V element)

Time complexity: O(n)

first
size_t first(V element, size_t startingIndex)

Time complexity: O(n) Returns size_t.max if no element found.

get
V get(size_t index)

Time complexity: O(n)

head
V head()

Time complexity: O(1)

head
V head(V element)

Time complexity: O(1)

isEmpty
bool isEmpty()

Is this container empty?

last
size_t last(V element, size_t startingIndex)

Time complexity: O(n) Returns size_t.max if no element found.

opApply
int opApply(int delegate(ref V value) dg)
prepend
CircularList prepend(V element)

Time complexity: O(1)

prepend
size_t prepend(IContainer!(V) e)

Time complexity: O(number of elements in e)

remove
size_t remove(V element, bool all)

Time complexity: O(n)

removeAt
CircularList removeAt(size_t index)

Time complexity: O(n)

removeHead
V removeHead()

Time complexity: O(1)

removeRange
size_t removeRange(size_t fromIndex, size_t toIndex)

Time complexity: O(n)

removeTail
V removeTail()

Time complexity: O(1)

replace
size_t replace(V oldElement, V newElement, bool all)

Time complexity: O(n)

replaceAt
CircularList replaceAt(size_t index, V element)

Time complexity: O(n)

reset
CircularList reset()

Reset the HashMap contents and optionally configure a new heap manager. This releases more memory than clear() does

subset
CircularList subset(size_t from, size_t length)

Time complexity: O(length)

tail
V tail()

Time complexity: O(1)

tail
V tail(V element)

Time complexity: O(1)

take
bool take(V v)

Time complexity: O(n)

toArray
V[] toArray(V[] dst)

Copy and return the contained set of values in an array, using the optional dst as a recipient (which is resized as necessary).

Properties

dup
CircularList dup [@property getter]

Make an independent copy of the list. Elements themselves are not cloned

iterator
Iterator iterator [@property getter]

Return a generic iterator for contained elements

size
size_t size [@property getter]

Return the number of elements contained

Examples

auto list = new CircularList!(int);
list.add(1);
list.add(2);
list.add(3);

int i = 1;
foreach(v; list)
{
    assert(v == i);
    i++;
}

auto iter = list.iterator;
iter.next();
iter.remove();                          // delete the first item

i = 2;
foreach(v; list)
{
    assert(v == i);
    i++;
}

// test insert functionality
iter = list.iterator;
iter.next;
iter.insert(4);

int[] compareto = [2, 4, 3];
i = 0;
foreach(v; list)
{
    assert(v == compareto[i++]);
}

Meta