Module collections

Source
Description

Collection trait hierarchy and generic collection helpers.

Declares the abstract-collection traits (Foldable, Mappable, Filterable, Keyed, Chainable, Indexed, Zippable) and the category aliases (Seq, Map, Set) that classify concrete types like Vec, HashMap, and HashSet.

Modules

binaryheap

BinaryHeap — max-heap priority queue.

btreemap

BTreeMap — ordered key-value collection.

btreeset

BTreeSet — ordered set of unique elements keyed by (Ord elem elem).

hashmap

HashMap — hash-based key-value collection.

hashset

HashSet — hash-based unique-element set.

linkedlist

LinkedList — doubly-linked list with O(1) push/pop at both ends.

vecdeque

VecDeque — double-ended queue with O(1) push/pop at both ends.

Data Types

Records

HashState

Opaque, seeded hasher state used internally by HashMap and HashSet

Abstractions

Traits

Chainable

Trait for collections that can be concatenated end-to-end.

Filterable

Trait for collections that support element selection by predicate.

Foldable

Trait for collections whose elements can be consumed by folding.

Indexed

Trait for collections with positional access by integer index.

Keyed

Trait for collections that support key-indexed access.

Map

Key-value-collection alias — any keyed, foldable type.

Mappable

Trait for collections whose elements can be transformed element-wise.

Seq

Sequential-collection alias — any type that is foldable, mappable,

Set

Unique-element collection trait.

Zippable

Trait for collections that can be combined element-wise.

Functions

Functions

hash-state-new

Construct a HashState with a fixed zero seed.

product-int

Multiply the elements of a Foldable collection of AnyInt values.

sum-int

Sum the elements of a Foldable collection of AnyInt values.

while

Classic while-loop word: repeatedly evaluate cond; while it yields

Trait Implementations

impl Default for HashMap(?540301 ?540302)

HashMap's .default MUST draw a seeded HashState via (HashState .new), carrying +Random. The HashState is produced and dropped here because hashmap-new-intrinsic does not yet accept a state argument (the runtime HashMap does not thread the seed through its bucket hasher). The declared +Random effect is still load-bearing: it documents that HashMap construction is non-deterministic per the HashDoS-resistance contract and forces callers to either sit inside a +Random handler or use an explicit zero-seed path through hash-state-new + hashmap-new-intrinsic.

.default ( (HashMap key val) )

impl Foldable for HashMap(?540484 ?540485)

.all ( (HashMap key val) [elem Bool ] Bool )

.any ( (HashMap key val) [elem Bool ] Bool )

.chunks-n ( (HashMap key val) (Int ..) (Vec (Vec elem)) )

.count ( (HashMap key val) (Int ..) )

.count-where ( (HashMap key val) [elem Bool ] (Int ..) )

.enumerate ( (HashMap key val) (Pair (Int ..) (Vec (Pair (Int ..) elem))) )

.filter-map ( (HashMap key val) [elem (Option b) ] (Vec b) )

.find ( (HashMap key val) [elem Bool ] (Option elem) )

.find-map ( (HashMap key val) [elem (Option b) ] (Option b) )

.first ( (HashMap key val) (Option elem) )

.flat-map ( (HashMap key val) [elem (Vec b n) ] (Vec b) )

.flatten ( (HashMap key val) (Vec elem) )

.fold ( (HashMap key val) acc [acc (Pair key val) acc ] acc )

.for-each ( (HashMap key val) [(Pair key val) ] )

.intersperse ( (HashMap key val) elem (Vec elem) )

.is-partitioned ( (HashMap key val) [elem Bool ] Bool )

.last ( (HashMap key val) (Option elem) )

.map-while ( (HashMap key val) [elem (Option b) ] (Vec b) )

.max-by ( (HashMap key val) [elem elem Ordering ] (Option elem) )

.max-by-key ( (HashMap key val) [elem key ] (Option elem) )

.min-by ( (HashMap key val) [elem elem Ordering ] (Option elem) )

.min-by-key ( (HashMap key val) [elem key ] (Option elem) )

.partition ( (HashMap key val) [elem Bool ] (Vec elem la) (Vec elem lb) )

.position ( (HashMap key val) [elem Bool ] (Option (Int ..)) )

.reduce ( (HashMap key val) [elem elem elem ] (Option elem) )

.rposition ( (HashMap key val) [elem Bool ] (Option (Int ..)) )

.scan ( (HashMap key val) state [state elem state (Option result) ] (Vec result) )

.skip ( (HashMap key val) (Int ..) (Vec elem) )

.skip-while ( (HashMap key val) [elem Bool ] (Vec elem) )

.step-by ( (HashMap key val) (Int ..) (Vec elem) )

.take ( (HashMap key val) (Int ..) (Vec elem) )

.take-while ( (HashMap key val) [elem Bool ] (Vec elem) )

.try-fold ( (HashMap key val) acc [acc elem (Result acc err) ] (Result acc err) )

.try-for-each ( (HashMap key val) [elem (Result Unit err) ] (Result Unit err) )

.try-reduce ( (HashMap key val) [elem elem (Result elem err) ] (Result (Option elem) err) )

.unzip ( (HashMap key val) (Pair (Vec a) (Vec b)) )

impl Keyed for HashMap(?540803 ?540804)

.contains-key ( key (HashMap key val) Bool )

.lookup ( key (HashMap key val) (Option val) )

impl Default for HashSet(?540305)

HashSet's .default mirrors HashMap's: draws (HashState .new) and discards the state, carrying +Random.

.default ( (HashSet elem) )

impl Foldable for HashSet(?540606)

.all ( (HashSet elem) [elem Bool ] Bool )

.any ( (HashSet elem) [elem Bool ] Bool )

.chunks-n ( (HashSet elem) (Int ..) (Vec (Vec elem)) )

.count ( (HashSet elem) (Int ..) )

.count-where ( (HashSet elem) [elem Bool ] (Int ..) )

.enumerate ( (HashSet elem) (Pair (Int ..) (Vec (Pair (Int ..) elem))) )

.filter-map ( (HashSet elem) [elem (Option b) ] (Vec b) )

.find ( (HashSet elem) [elem Bool ] (Option elem) )

.find-map ( (HashSet elem) [elem (Option b) ] (Option b) )

.first ( (HashSet elem) (Option elem) )

.flat-map ( (HashSet elem) [elem (Vec b n) ] (Vec b) )

.flatten ( (HashSet elem) (Vec elem) )

.fold ( (HashSet elem) acc [acc elem acc ] acc )

.for-each ( (HashSet elem) [elem ] )

.intersperse ( (HashSet elem) elem (Vec elem) )

.is-partitioned ( (HashSet elem) [elem Bool ] Bool )

.last ( (HashSet elem) (Option elem) )

.map-while ( (HashSet elem) [elem (Option b) ] (Vec b) )

.max-by ( (HashSet elem) [elem elem Ordering ] (Option elem) )

.max-by-key ( (HashSet elem) [elem key ] (Option elem) )

.min-by ( (HashSet elem) [elem elem Ordering ] (Option elem) )

.min-by-key ( (HashSet elem) [elem key ] (Option elem) )

.partition ( (HashSet elem) [elem Bool ] (Vec elem la) (Vec elem lb) )

.position ( (HashSet elem) [elem Bool ] (Option (Int ..)) )

.reduce ( (HashSet elem) [elem elem elem ] (Option elem) )

.rposition ( (HashSet elem) [elem Bool ] (Option (Int ..)) )

.scan ( (HashSet elem) state [state elem state (Option result) ] (Vec result) )

.skip ( (HashSet elem) (Int ..) (Vec elem) )

.skip-while ( (HashSet elem) [elem Bool ] (Vec elem) )

.step-by ( (HashSet elem) (Int ..) (Vec elem) )

.take ( (HashSet elem) (Int ..) (Vec elem) )

.take-while ( (HashSet elem) [elem Bool ] (Vec elem) )

.try-fold ( (HashSet elem) acc [acc elem (Result acc err) ] (Result acc err) )

.try-for-each ( (HashSet elem) [elem (Result Unit err) ] (Result Unit err) )

.try-reduce ( (HashSet elem) [elem elem (Result elem err) ] (Result (Option elem) err) )

.unzip ( (HashSet elem) (Pair (Vec a) (Vec b)) )

impl Foldable for ?540661..?540662

.all ( a..b [elem Bool ] Bool )

.any ( a..b [elem Bool ] Bool )

.chunks-n ( a..b (Int ..) (Vec (Vec elem)) )

.count ( a..b (Int ..) )

.count-where ( a..b [elem Bool ] (Int ..) )

.enumerate ( a..b (Pair (Int ..) (Vec (Pair (Int ..) elem))) )

.filter-map ( a..b [elem (Option b) ] (Vec b) )

.find ( a..b [elem Bool ] (Option elem) )

.find-map ( a..b [elem (Option b) ] (Option b) )

.first ( a..b (Option elem) )

.flat-map ( a..b [elem (Vec b n) ] (Vec b) )

.flatten ( a..b (Vec elem) )

.fold ( (Int ..)..(Int ..) acc [acc (Int ..) acc ] acc )

.for-each ( (Int ..)..(Int ..) [(Int ..) ] )

.intersperse ( a..b elem (Vec elem) )

.is-partitioned ( a..b [elem Bool ] Bool )

.last ( a..b (Option elem) )

.map-while ( a..b [elem (Option b) ] (Vec b) )

.max-by ( a..b [elem elem Ordering ] (Option elem) )

.max-by-key ( a..b [elem key ] (Option elem) )

.min-by ( a..b [elem elem Ordering ] (Option elem) )

.min-by-key ( a..b [elem key ] (Option elem) )

.partition ( a..b [elem Bool ] (Vec elem la) (Vec elem lb) )

.position ( a..b [elem Bool ] (Option (Int ..)) )

.reduce ( a..b [elem elem elem ] (Option elem) )

.rposition ( a..b [elem Bool ] (Option (Int ..)) )

.scan ( a..b state [state elem state (Option result) ] (Vec result) )

.skip ( a..b (Int ..) (Vec elem) )

.skip-while ( a..b [elem Bool ] (Vec elem) )

.step-by ( a..b (Int ..) (Vec elem) )

.take ( a..b (Int ..) (Vec elem) )

.take-while ( a..b [elem Bool ] (Vec elem) )

.try-fold ( a..b acc [acc elem (Result acc err) ] (Result acc err) )

.try-for-each ( a..b [elem (Result Unit err) ] (Result Unit err) )

.try-reduce ( a..b [elem elem (Result elem err) ] (Result (Option elem) err) )

.unzip ( a..b (Pair (Vec a) (Vec b)) )

impl Chainable for Vec(?540812 ?540813)

.chain ( (Vec elem len) (Vec elem len) (Vec elem len) )

impl Filterable for Vec(?540792 ?540793) | Vec(?540792 ?540793)

.filter ( (Vec elem len) [elem Bool ] (Vec elem len) )

impl Foldable for Vec(?540398 ?540399)

.all ( (Vec elem len) [elem Bool ] Bool )

.any ( (Vec elem len) [elem Bool ] Bool )

.chunks-n ( (Vec elem) (Int ..) (Vec (Vec elem)) )

Vec-specific chunks-n: Pair(completed_chunks, current_chunk) accumulator; finaliser flushes any non-empty trailing chunk.

.count ( (Vec elem len) (Int ..) )

.count-where ( (Vec elem len) [elem Bool ] (Int ..) )

.enumerate ( (Vec elem len) (Pair (Int ..) (Vec (Pair (Int ..) elem))) )

.filter-map ( (Vec elem len) [elem (Option b) ] (Vec b) )

.find ( (Vec elem len) [elem Bool ] (Option elem) )

.find-map ( (Vec elem len) [elem (Option b) ] (Option b) )

.first ( (Vec elem len) (Option elem) )

.flat-map ( (Vec elem) [elem (Vec b) ] (Vec b) )

Vec-specific flat-map: call f per element, flatten the results.

.flatten ( (Vec (Vec inner-elem)) (Vec inner-elem) )

Vec-specific flatten: nested fold pushing inner Vec's elements into the outer accumulator. Element type is concretely Vec-shaped here, so .push on the accumulator resolves.

.fold ( (Vec elem len) acc [acc elem acc ] acc )

.for-each ( (Vec elem len) [elem ] )

.intersperse ( (Vec elem len) elem (Vec elem) )

.is-partitioned ( (Vec elem len) [elem Bool ] Bool )

.last ( (Vec elem len) (Option elem) )

.map-while ( (Vec elem len) [elem (Option b) ] (Vec b) )

.max-by ( (Vec elem len) [elem elem Ordering ] (Option elem) )

.max-by-key ( (Vec elem len) [elem key ] (Option elem) )

.min-by ( (Vec elem len) [elem elem Ordering ] (Option elem) )

.min-by-key ( (Vec elem len) [elem key ] (Option elem) )

.partition ( (Vec elem len) [elem Bool ] (Vec elem la) (Vec elem lb) )

.position ( (Vec elem len) [elem Bool ] (Option (Int ..)) )

.reduce ( (Vec elem len) [elem elem elem ] (Option elem) )

.rposition ( (Vec elem len) [elem Bool ] (Option (Int ..)) )

.scan ( (Vec elem len) state [state elem state (Option result) ] (Vec result) )

.skip ( (Vec elem len) (Int ..) (Vec elem) )

.skip-while ( (Vec elem len) [elem Bool ] (Vec elem) )

.step-by ( (Vec elem len) (Int ..) (Vec elem) )

.take ( (Vec elem len) (Int ..) (Vec elem) )

.take-while ( (Vec elem len) [elem Bool ] (Vec elem) )

.try-fold ( (Vec elem len) acc [acc elem (Result acc err) ] (Result acc err) )

.try-for-each ( (Vec elem len) [elem (Result Unit err) ] (Result Unit err) )

.try-reduce ( (Vec elem len) [elem elem (Result elem err) ] (Result (Option elem) err) )

.unzip ( (Vec (Pair a b)) (Pair (Vec a) (Vec b)) )

Vec-specific unzip: each element's .a / .b go onto matching Vecs.

impl Indexed for Vec(?540821 ?540822)

.at ( (Int ..) (Vec elem len) (Option elem) )

.size ( (Vec elem len) (Int ..) )

impl Mappable for Vec(?540781 ?540782) | Vec(?540783 ?540782)

.map ( (Vec a len) [a b ] (Vec b len) )

impl Zippable for Vec(?540831 ?540832)

.zip ( (Vec a la) (Vec b lb) (Vec (Pair a b) lc) )