Collection

Array based collection of items.

Retains item order when during add/remove operations.

Optionally destroys removed objects when instanciated with ownItems = true.

Destructor

~this
~this()

removes all items on destroy

Members

Functions

add
void add(T item, size_t index)

insert new item in specified position

addAll
void addAll(Collection!(T, ownItems) v)

add all items from other collection

clear
void clear()

remove all items

indexOf
size_t indexOf(T item)

returns index of first occurence of item, size_t.max if not found

opApply
int opApply(int delegate(ref T param) op)

support of foreach with reference

opIndex
T opIndex(size_t index)

access item by index

opOpAssign
Collection opOpAssign(T item)

support for appending (~=, +=) and removing by value (-=)

pushBack
void pushBack(T item)

insert item at end of collection

pushFront
void pushFront(T item)

insert item at beginning of collection

remove
T remove(size_t index)

remove single item, returning removed item

removeValue
bool removeValue(T value)

remove single item by value - if present in collection, returning true if item was found and removed

Properties

back
T back [@property getter]

peek last item

empty
bool empty [@property getter]

returns true if there are no items in collection

front
T front [@property getter]

peek first item

length
size_t length [@property getter]

returns number of items in collection

length
size_t length [@property setter]

returns number of items in collection

popBack
T popBack [@property getter]

remove last item

popFront
T popFront [@property getter]

remove first item

size
size_t size [@property getter]

returns currently allocated capacity (may be more than length)

size
size_t size [@property setter]

change capacity (e.g. to reserve big space to avoid multiple reallocations)

Meta