HashSet_AB

A manually managed hashset that uses buckets 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.

Members

Functions

bucket
BucketT* bucket(const size_t index)

Provides an access to the buckets.

bucketCount
size_t bucketCount()
byKey
auto byKey()
clear
void clear()

Empties the set.

collisions
size_t collisions()
count
size_t 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 used by the set.

opBinaryRight
K* opBinaryRight(auto ref KK key)

Tests the presence of a key in the set.

remove
bool remove(auto ref K key)

Tries to remove a key from the set.

reserve
void reserve(size_t value)

Reserves buckets for at least N supplemental keys.

Examples

1 HashSet_AB!string commands;
2 // can insert up to 16 elements without reallocation
3 commands.reserve(15);
4 assert(commands.bucketCount == 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