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.

Pair

Collection pair that implements Compare interface for use in sorted collections

Implements: Compare, Stringify

Example

pair := Collection.Pair->New(IntRef->New(1), "one")<IntRef, String>;
pair->GetFirst()->PrintLine();
pair->GetSecond()->PrintLine();
pair->ToString()->PrintLine();

Operations

Compare #

Compares two objects based upon first value

method : public : Compare(rhs:System.Compare) ~ Int

Parameters

NameTypeDescription
rhsCompareanother pair (the form a sorted collection passes) or the first value of another pair

Return

TypeDescription
Int0 if equal, -1 if right-hand side i greater, 1 if left-hand side is greater

Example

a := Collection.Pair->New(IntRef->New(1), "one")<IntRef, String>;
b := Collection.Pair->New(IntRef->New(2), "two")<IntRef, String>;
a->Compare(b->GetFirst())->PrintLine(); # -1

GetFirst #

Gets the first value

method : public : GetFirst() ~ F

Return

TypeDescription
Ffirst value

Example

pair := Collection.Pair->New(IntRef->New(7), "seven")<IntRef, String>;
pair->GetFirst()->PrintLine(); # 7

GetSecond #

Gets the second value

method : public : GetSecond() ~ S

Return

TypeDescription
Ssecond value

Example

pair := Collection.Pair->New(IntRef->New(3), "three")<IntRef, String>;
pair->GetSecond()->PrintLine(); # three

HashID #

Returns the class default hash ID

method : public : HashID() ~ Int

Return

TypeDescription
Inthash ID

Example

pair := Collection.Pair->New(IntRef->New(42), "answer")<IntRef, String>;
pair->HashID()->PrintLine();

New # constructor

Default constructor

New(first:F, second:S)

Parameters

NameTypeDescription
firstFcompare object
secondSobject

Example

pair := Collection.Pair->New(IntRef->New(1), "one")<IntRef, String>;
pair->GetFirst()->PrintLine();  # 1
pair->GetSecond()->PrintLine(); # one

SetFirst #

Sets the first value

method : public : SetFirst(first:F) ~ Nil

Parameters

NameTypeDescription
firstFfirst value

Example

pair := Collection.Pair->New(IntRef->New(1), "one")<IntRef, String>;
pair->SetFirst(IntRef->New(99));
pair->GetFirst()->PrintLine(); # 99

SetSecond #

Sets the second value

method : public : SetSecond(second:S) ~ Nil

Parameters

NameTypeDescription
secondSsecond value

Example

pair := Collection.Pair->New(IntRef->New(1), "one")<IntRef, String>;
pair->SetSecond("ONE");
pair->GetSecond()->PrintLine(); # ONE

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

Example

pair := Collection.Pair->New(IntRef->New(5), "five")<IntRef, String>;
pair->ToString()->PrintLine(); # {5,five}