collections
Higher-level data structures: Counter, Stack, PriorityQueue, Deque, Set, and OrderedMap.
Import
import collectionsTypes
collections.Counter(arr: [any]) -> map
Returns a map of element counts from the array.
collections.Stack() -> Stack
Creates a LIFO stack. Methods: push(v), pop(), peek(), is_empty(), len().
collections.PriorityQueue() -> PriorityQueue
Min-heap priority queue. Elements with lower priority values are dequeued first.
collections.Deque() -> Deque
Double-ended queue supporting efficient push/pop from both ends.
collections.Set(arr?: [any]) -> Set
Set of unique elements. Pass an array to initialize. Supports add, remove, has, len.
collections.OrderedMap() -> OrderedMap
Map that preserves insertion order. Useful when iteration order matters.
Examples
scratch.xs