v2026.11.3
All Bundles
Bundle

Generic collections library: Vector (dynamic array), List (linked list), Map (ordered binary tree, O(log n)), Hash (hash table), Set, HashSet, SetHash, MultiMap, MultiHash, Stack, Queue, and Pair. Provides typed iteration, sorting, filtering, and functional operations (Reduce, Any, All). Compile with -lib gen_collect.

BiMap

Bidirectional map: every key has exactly one value and every value exactly one key, so lookups work in both directions in O(1) expected. Inserting a key or a value that is already present replaces the old pairing. Built from two Hash tables.

Operations

Empty #

Removes every pair

method : public : Empty() ~ Nil

FindKey #

Finds the key paired with a value

method : public : FindKey(value:B) ~ A

Parameters

NameTypeDescription
valueBvalue

Return

TypeDescription
Akey, or Nil if absent

FindValue #

Finds the value paired with a key

method : public : FindValue(key:A) ~ B

Parameters

NameTypeDescription
keyAkey

Return

TypeDescription
Bvalue, or Nil if absent

GetKeys #

Gets the keys, order unspecified

method : public : GetKeys() ~ Vector<A>

Return

TypeDescription
Vector<A>vector of keys

GetValues #

Gets the values, order unspecified

method : public : GetValues() ~ Vector<B>

Return

TypeDescription
Vector<B>vector of values

HasKey #

Checks whether a key is present

method : public : HasKey(key:A) ~ Bool

Parameters

NameTypeDescription
keyAkey

Return

TypeDescription
Booltrue if present

HasValue #

Checks whether a value is present

method : public : HasValue(value:B) ~ Bool

Parameters

NameTypeDescription
valueBvalue

Return

TypeDescription
Booltrue if present

Insert #

Pairs a key with a value, first dropping any existing pair that uses that key or that value

method : public : Insert(key:A, value:B) ~ Bool

Parameters

NameTypeDescription
keyAkey
valueBvalue

Return

TypeDescription
Booltrue if stored, false if either is Nil

Example

m := Collection.BiMap->New()<String, IntRef>;
m->Insert("a", IntRef->New(1));
m->Insert("b", IntRef->New(1)); # replaces ("a", 1)
m->Size()->PrintLine();         # 1

IsEmpty #

Checks for no pairs

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty

New # constructor

Default constructor

New()

Example

m := Collection.BiMap->New()<String, IntRef>;
m->Insert("one", IntRef->New(1));
m->FindKey(IntRef->New(1))->PrintLine(); # one

RemoveKey #

Removes the pair holding a key

method : public : RemoveKey(key:A) ~ Bool

Parameters

NameTypeDescription
keyAkey

Return

TypeDescription
Booltrue if a pair was removed

RemoveValue #

Removes the pair holding a value

method : public : RemoveValue(value:B) ~ Bool

Parameters

NameTypeDescription
valueBvalue

Return

TypeDescription
Booltrue if a pair was removed

Size #

Gets the number of pairs

method : public : Size() ~ Int

Return

TypeDescription
Intsize