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.

PriorityMap

Indexed min-priority queue: each key is held once with a Float priority that can be lowered or raised later (decrease-key), which the plain Heap cannot do. Push of a present key updates it. Push, Pop, Remove and priority updates are O(log n); Has, Priority and Peek are O(1) expected. The smallest priority comes out first.

Operations

Empty #

Removes every key

method : public : Empty() ~ Nil

Has #

Checks whether a key is present

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

Parameters

NameTypeDescription
keyTkey

Return

TypeDescription
Booltrue if present

IsEmpty #

Checks for no keys

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty

New # constructor

Default constructor

New()

Example

q := Collection.PriorityMap->New()<String>;
q->Push("far", 9.0); q->Push("near", 1.0);
q->Pop()->PrintLine(); # near

Peek #

Gets the key with the smallest priority without removing it

method : public : Peek() ~ T

Return

TypeDescription
Tkey, or Nil if empty

PeekPriority #

Gets the smallest priority

method : public : PeekPriority() ~ Float

Return

TypeDescription
Floatpriority, 0.0 if empty

Pop #

Removes and returns the key with the smallest priority

method : public : Pop() ~ T

Return

TypeDescription
Tkey, or Nil if empty

Example

q := Collection.PriorityMap->New()<String>;
q->Push("b", 2.0); q->Push("a", 1.0);
q->Pop()->PrintLine(); # a

Priority #

Gets the priority of a key

method : public : Priority(key:T) ~ Float

Parameters

NameTypeDescription
keyTkey

Return

TypeDescription
Floatpriority, 0.0 if the key is absent (use Has to tell)

Push #

Adds a key, or changes its priority if it is already present

method : public : Push(key:T, priority:Float) ~ Nil

Parameters

NameTypeDescription
keyTkey (Nil is ignored)
priorityFloatpriority, smaller comes out first

Example

q := Collection.PriorityMap->New()<String>;
q->Push("a", 5.0);
q->Push("a", 2.0); # decrease-key
q->Priority("a")->PrintLine(); # 2

Remove #

Removes a key wherever it is in the queue

method : public : Remove(key:T) ~ Bool

Parameters

NameTypeDescription
keyTkey

Return

TypeDescription
Booltrue if it was present

Size #

Gets the number of keys

method : public : Size() ~ Int

Return

TypeDescription
Intsize