HashMap_LP

A manually managed hashmap that uses linear probing to solve the collisions.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

byKey
auto byKey()

Returns an input range consisting of each key.

byKeyValue
auto byKeyValue()

Returns an input range consisting of each non-null key-value pair.

byValue
auto byValue()

Returns an input range consisting of each value.

clear
void clear()

Clears and empties the set.

count
size_t count()

Returns the key-value pairs count.

insert
bool insert(ref K key, auto ref V value)
bool insert(K key, V value)

Tries to insert a key-value pair in the map.

minimize
void minimize()

Minimizes the memory usage.

opBinaryRight
V* opBinaryRight(auto ref KK key)

Tests the presence of a key in the set.

opIndex
V opIndex(auto ref KK key)

Provides an access to the key-value pairs.

opIndexAssign
void opIndexAssign(auto ref V value, auto ref KK key)

Support for inserting using the array syntax. Forwards insert().

opIndexAssign
void opIndexAssign(auto ref V2 value, auto ref KK1 key1, auto ref KK2 key2)

Support for assigning to the value when the value is itself an AA.

opIndexOpAssign
void opIndexOpAssign(auto ref VV value, auto ref KK key)

Support for the assignment operators on a value.

opOpAssign
bool opOpAssign(auto ref K key)

Support for appending an element.

remove
bool remove(auto ref K key)

Tries to remove a key from the set.

reserve
void reserve(size_t value)

Reserves slots for at least N supplemental key-value pairs.

slot
MapPair* slot(const size_t index)

Provides an access to the key-value pairs.

slotCount
size_t slotCount()

Returns the slots counts.

Examples

1 HashMap_LP!(string, size_t) stock;
2 // can insert up to 16 elements without reallocation
3 stock.reserve(15);
4 assert(stock.slotCount == 16);
5 // appends elements, various syntax allowed
6 stock.insert("pen", 8);
7 stock["gum"] += 32;
8 stock["ruler"] += 12;
9 stock ~= "tape roll";
10 // test for inclusion, various syntax allowed
11 assert("gum" in stock);
12 assert(stock["ruler"] == 12);
13 assert(stock["tape roll"] == 0);
14 // remove something
15 stock.remove("ruler");
16 assert("ruler" !in stock);
17 // empties and frees memory
18 stock.clear;
19 // manually managed implies to destruct by hand
20 import iz.memory;
21 destruct(stock);

Meta