HashTable

A hash table associates a set of keys with a set of values. Each key/value pair is an entry in the table. Given a key, you can look up its corresponding value. You can add new key/value pairs and remove entries by key. If you add a new value for an existing key, it replaces the previous entry.

The table will automatically resize when it's close to being full, which means you can never fill up the table.

Constructors

this
this(int capacity)

Takes in the default capacity

Members

Functions

findEntry
Entry* findEntry(string key)

Looks up an entry in the array, and returns it if it's key is empty or matching

findEntryIndex
uint findEntryIndex(string key)

Finds the index of the entry

get
Nullable!EntryValue get(string key)

Gets an entry from the table

getAll
EntryValue[] getAll()
Undocumented in source. Be warned that the author may not have intended to support it.
hasEntry
bool hasEntry(string key)

Checks if the table contains a certain element

merge
void merge(HashTable table)

Merges the entries of another table into the current tables entries

remove
bool remove(string key)

Removes an item from the table

set
bool set(string key, T value)

Adds a new entry, with the given name and value, to the table

set
bool set(string key, EntryValue value)

Adds a new entry, with the given name and value, to the table

Variables

capacity
int capacity;

The max amount of entries in the table

count
int count;

The size of the table. This keeps tracks of how many non-empty entries the table has

entries
Entry[] entries;

An array of all the entries

Meta