Container
The Container module provides advanced data structures beyond the core List, Map, and Set types. Includes queues, stacks, heaps, trees, tries, and specialized structures like bloom filters.
All container operations return new structures rather than modifying in place, following Kit's functional programming principles.
Deque
Double-ended queue supporting efficient insertion and removal at both ends.
deque = Deque.empty |> Deque.push-front 1 |> Deque.push-front 2
# deque contains [2, 1]
None if empty.Heap
Min-heap (priority queue) that always provides access to the smallest element.
heap = Heap.empty |> Heap.push 5 |> Heap.push 3 |> Heap.push 7
Heap.peek heap # => Some 3 (smallest)
Queue
FIFO (first-in, first-out) queue.
q = Queue.empty |> Queue.enqueue "first" |> Queue.enqueue "second"
Queue.dequeue q # => Some "first"
LinkedList
Singly-linked list with efficient prepend operations.
Trie
Prefix tree for efficient string key operations and prefix matching.
trie = Trie.empty |> Trie.insert "hello" |> Trie.insert "help"
Trie.starts-with? "hel" trie # => true
Zipper
List with a movable cursor for efficient local updates.
SkipList
Probabilistic sorted data structure with O(log n) operations.
Bloom
Probabilistic set for fast membership testing (may have false positives).
# 1000-bit filter with 3 hash functions
filter = Bloom.create 1000 3
contains? may return false positives but never false negatives.BinaryTree
Simple binary search tree (unbalanced).
tree = BinaryTree.empty
|> BinaryTree.insert 5
|> BinaryTree.insert 3
|> BinaryTree.insert 7
BinaryTree.to-list tree # => [3, 5, 7]
AVLTree
Self-balancing binary search tree with guaranteed O(log n) operations.
RBTree
Red-black tree with guaranteed O(log n) operations.
BTree
B-tree optimized for disk-based storage with high branching factor.
MerkleTree
Hash tree for data integrity verification.
tree = MerkleTree.from-list ["a", "b", "c", "d"]
MerkleTree.root-hash tree # => Some "58c89d..."