HashSet_LP

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

Constructors

this
this(A a)

Constructs using either a list of keys, arrays of keys, or both.

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 that consists of each non-null key.

clear
void clear()

Clears and empties the set.

count
size_t count()

Returns the keys count.

insert
bool insert(ref K key)
bool insert(K key)
bool insert(auto ref KK keys)
bool insert(auto ref KK keys)

Tries to insert key(s) in the set.

minimize
void minimize()

Minimizes the memory usage.

opBinaryRight
K* opBinaryRight(auto ref KK key)

Tests the presence of a key in the set.

opOpAssign
auto opOpAssign(auto ref KK keys)

Support for appending element(s). Forwards insert().

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 keys.

slot
K* slot(const size_t index)

Provides an access to the keys.

slotCount
size_t slotCount()

Returns the slots count.

Examples

1 HashSet_LP!string commands;
2 // can insert up to 16 elements without reallocation
3 commands.reserve(15);
4 assert(commands.slotCount == 16);
5 // appends elements
6 commands.insert("move");
7 commands.insert("insert");
8 commands.insert("delete");
9 // test for inclusion
10 assert("move" in commands);
11 // remove something
12 commands.remove("insert");
13 assert(commands.count == 2);
14 assert("insert" !in commands);
15 // empties and frees memory
16 commands.clear;
17 // manually managed implies to destruct by hand
18 import iz.memory;
19 destruct(commands);

Meta