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.

BloomFilter

Bloom filter: a compact set that can say "definitely not present" or "probably present". Add and MightContain are O(k) bit operations; memory is a fixed number of bits per expected key. There are no false negatives; the false positive rate is about 1% at 10 bits per key and 0.1% at 15. Keys cannot be removed.

Operations

Add #

Adds a key

method : public : Add(key:T) ~ Nil

Parameters

NameTypeDescription
keyTkey (Nil is ignored)

Example

b := Collection.BloomFilter->New(100, 10)<String>;
b->Add("x");
b->Count()->PrintLine(); # 1

Bits #

Gets the number of bits in the filter

method : public : Bits() ~ Int

Return

TypeDescription
Intbits

Count #

Gets the number of Add calls (repeats count)

method : public : Count() ~ Int

Return

TypeDescription
Intcount

Empty #

Removes every key

method : public : Empty() ~ Nil

MightContain #

Tests a key

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

Parameters

NameTypeDescription
keyTkey

Return

TypeDescription
Boolfalse if the key was definitely never added, true if it probably was

Example

b := Collection.BloomFilter->New(100, 10)<String>;
b->Add("x");
b->MightContain("y")->PrintLine(); # almost certainly false

New # constructor

Creates a filter

New(expected:Int, bits_per_key:Int)

Parameters

NameTypeDescription
expectedIntnumber of keys you expect to add (at least 1)
bits_per_keyIntbits of memory per expected key, 10 gives about 1% false positives

Example

b := Collection.BloomFilter->New(1000, 10)<String>;
b->Add("apple");
b->MightContain("apple")->PrintLine(); # true