Map
Map: Map, insert, set, remove, size, capacity, resize, operator[], contains, empty, loadFactor, iterator
MapIterator: MapIterator, hasValue, value, increment
Functions: convertHash
struct MapEntry<Key: Hashable, Value>
A key-value pair stored in a map.
key
Key key;The entry's key.
value
Value value;The entry's value.
struct Map<Key: Hashable, Value>
A hash map from keys to values.
Map
Map()Initializes an empty map
insert
void insert(Key key, Value value)Inserts an element into the map. The key must not already be in the map.
set
void set(Key key, Value value)Inserts, or updates an existing value.
remove
void remove(Key& e)Removes an element from the map, if it exists there.
size
int size()Returns the number of entries.
capacity
int capacity()Returns the number of buckets.
resize
void resize()Resizes the map. This includes copying the old table into a new, bigger one
operator[]
Value&? operator[](Key& e)Returns the value for the given key, or null.
contains
bool contains(Key& e)Checks if e is part of the map.
empty
bool empty()Returns true if the map has no entries.
loadFactor
float64 loadFactor()Returns the load factor for the map. This is used to increase the map size once the load factor gets too big.
iterator
MapIterator<Key, Value> iterator()Iterate over the map
struct MapIterator<Key, Value>: Copyable, Iterator<MapEntry<Key, Value>&>
Iterates over the entries of a map.
MapIterator
MapIterator(Map<Key, Value>& map)Initializes an iterator over the given map.
hasValue
bool hasValue()Returns true if there are more entries.
value
MapEntry<Key, Value>& value()Returns the current entry.
increment
void increment()Advances to the next entry.
convertHash
int convertHash(uint64 hash)Converts a hash into a bucket index.