dlangui.core.collections

This module implements object collection.

Wrapper around array of objects, providing a set of useful operations, and handling of object ownership.

Optionally can be owner of its items if instanciated with ownItems=true - will destroy removed items.

More...

Members

Structs

Collection
struct Collection(T, bool ownItems = false)

Array based collection of items.

ObjectList
struct ObjectList(T)

object list holder, owning its objects - on destroy of holder, all own objects will be destroyed

Detailed Description

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

Meta

License

Boost License 1.0

Authors

Vadim Lopatin, coolreader.org@gmail.com