dlangui.core.collections
DLANGUI library.
This module implements array based collection.
Synopsis:
import dlangui.core.collections;
// add
Collection!Widget widgets;
widgets ~= new Widget("id1");
widgets ~= new Widget("id2");
Widget w3 = new Widget("id3");
widgets ~= w3;
// remove by index
widgets.remove(1);
// foreach
foreach(w; widgets)
writeln("widget: ", w.id);
// remove by value
widgets -= w3;
writeln(widgets[0].id);
License:
Boost License 1.0
Authors:
Vadim Lopatin, coolreader.org@gmail.com
- struct Collection(T, bool ownItems = false);
- array based collection of items
retains item order when during add/remove operations
- bool empty();
- returns true if there are no items in collection
- size_t length();
- returns number of items in collection
- size_t size();
- returns currently allocated capacity (may be more than length)
- void size(size_t newSize);
- change capacity (e.g. to reserve big space to avoid multiple reallocations)
- void length(size_t newSize);
- returns number of items in collection
- T opIndex(size_t index);
- access item by index
- void add(T item, size_t index = size_t.max);
- insert new item in specified position
- void addAll(ref Collection!(T, ownItems) v);
- add all items from other collection
- Collection opOpAssign(string op)(T item);
- support for appending (~=, +=) and removing by value (-=)
- size_t indexOf(T item);
- returns index of first occurence of item, size_t.max if not found
- T remove(size_t index);
- remove single item, returning removed item
- bool removeValue(T value);
- remove single item by value - if present in collection, returning true if item was found and removed
- int opApply(int delegate(ref T param) op);
- support of foreach with reference
- void clear();
- remove all items
- T popFront();
- remove first item
- void pushFront(T item);
- insert item at beginning of collection
- T popBack();
- remove last item
- void pushBack(T item);
- insert item at end of collection
- T front();
- peek first item
- T back();
- peek last item
Page generated by Ddoc. Vadim Lopatin, 2014