v2025.6.2
All Bundles

Hash

Hash unordered table of generics

# insert elements
hash := Collection.Hash->New()<IntRef, String>;
hash->Insert(415, "San Francisco");
hash->Insert(510, "Oakland");
hash->Insert(925, "East Bay");

# get size
hash->Size()->PrintLine();

# get value by key
hash->Find(510)->PrintLine();

# get key/values
key_values := hash->GetKeyValues()<Pair<IntRef, String>>;
each(key_value := key_values) {
   key_value->GetFirst()->PrintLine();
};

# get values
values := hash->GetValues()<String>;
each(value := values) {
   value->PrintLine();
};

# check for key
hash->Has(408)->PrintLine();

Operations

Empty

Clears the map

method : public : Empty() ~ Nil

Find

Searches for a value in a hash

method : public : native : Find(key:K) ~ V

Parameters

NameTypeDescription
keyKsearch key

Return

TypeDescription
Vfound value, Nil if not found

GetCapacity

Gets the hash table capacity

method : public : GetCapacity() ~ Hash->Capacity

Return

TypeDescription
Hash->Capacityhash table capacity

GetKeyValues

Gets a collection of key/value pairs

method : public : GetKeyValues() ~ Vector<Pair<K,V>>

Return

TypeDescription
Vector<Pair<K,V>>vector of key/value pairs

GetKeys

Get a collection of keys

method : public : native : GetKeys() ~ Vector<K>

Return

TypeDescription
Vector<K>vector of keys

GetValues

Gets a collection of values

method : public : native : GetValues() ~ Vector<V>

Return

TypeDescription
Vector<V>vector of values

Has

Checks for a value in a hash

method : public : Has(key:K) ~ Bool

Parameters

NameTypeDescription
keyKsearch key

Return

TypeDescription
Booltrue if found, false otherwise

Insert

Inserts a value into the hash

method : public : Insert(key:K, value:V) ~ Nil

Parameters

NameTypeDescription
keyKkey
valueVvalue

IsAutoResize

Gets auto-resize setting

method : public : IsAutoResize() ~ Bool

Return

TypeDescription
Booltrue if auto-resize is set, false otherwise

IsEmpty

Checks to see if the hash table is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

New

Default constructor

New(auto_resize:Bool)

Parameters

NameTypeDescription
auto_resizeBoolif true, automatically resized the hash table

New

Default constructor

New(capacity:Hash->Capacity, auto_resize:Bool)

Parameters

NameTypeDescription
capacityHash->Capacitycapacity of hash table
auto_resizeBoolif true, automatically resized the hash table

Remove

Removes a value from the hash

method : public : native : Remove(key:K) ~ Bool

Parameters

NameTypeDescription
keyKkey for value to remove

Resize

Resizes the hash table

method : public : native : Resize(capacity:Hash->Capacity, auto_resize:Bool) ~ Nil

Parameters

NameTypeDescription
capacityHash->Capacitytable capacity
auto_resizeBooltrue for hash table auto resizing, false otherwise

SetAutoResize

Set auto-resize setting

method : public : SetAutoResize(auto_resize:Bool) ~ Nil

Parameters

NameTypeDescription
auto_resizeBooltrue if auto-resize is enable, false otherwise

SetCapacity

Sets hash table capacity

method : public : SetCapacity(capacity:Hash->Capacity) ~ Nil

Parameters

NameTypeDescription
capacityHash->Capacityhash table capacity

Size

Size of map

method : public : Size() ~ Int

Return

TypeDescription
Intsize of map

ToString

Formats the collection into a string. If an element implements the 'Stringify' interface, it's 'ToString()' is called.

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation