AssocArray

Members

Functions

asRange
auto asRange()

Gets a range of key/values for aa.

getLvalue
V* getLvalue(const(K) key)

Lookup value associated with key and return the address to it. If the key has not been added, it adds it and returns the address to the new value.

length
size_t length()
opIndex
V opIndex(const(K) key)

Lookup and return the value associated with key, if the key has not been added, it returns null.

Examples

1 auto foo = new Object();
2 auto bar = new Object();
3 
4 AssocArray!(Object, Object) aa;
5 
6 assert(aa[foo] is null);
7 assert(aa.length == 0);
8 
9 auto fooValuePtr = aa.getLvalue(foo);
10 *fooValuePtr = bar;
11 
12 assert(aa[foo] is bar);
13 assert(aa.length == 1);

Meta