The built-in dynamic array type. All Seen programs have access to Array<T>.
let arr = Array<Int>() // empty
let arr = [1, 2, 3, 4, 5] // literal
let arr = Array<Int>.withLength(100) // pre-sized
| Method | Return | Description |
|---|---|---|
push(value: T) | Void | Append element |
pop() | T | Remove and return last element |
get(index: Int) | T | Get element at index |
set(index: Int, value: T) | Void | Set element at index |
length() | Int | Number of elements |
| Function | Description |
|---|---|
seen_arr_new_str() | Create empty string array |
seen_arr_new_ptr() | Create empty pointer array |
seen_arr_push_str(arr, s) | Push string |
seen_arr_push_i64(arr, val) | Push integer |
seen_arr_push_f64(arr, val) | Push float |
seen_arr_push_ptr(arr, ptr) | Push pointer |
seen_arr_get_str(arr, idx) | Get string at index |
seen_arr_get_i64(arr, idx) | Get integer at index |
seen_arr_set_i64(arr, idx, val) | Set integer at index |
seen_arr_set_str(arr, idx, s) | Set string at index |
seen_arr_length(arr) | Get array length |
var names = Array<String>()
names.push("Alice")
names.push("Bob")
names.push("Charlie")
for name in names {
println("Hello, {name}!")
}
Contiguous vector with amortized O(1) push/pop and O(1) indexed access. Vec<T> is the preferred performance-oriented growable sequence when callers need repeated get, set, iteration, or conversion back to Array<T>.
import collections.vec
let v = Vec<Int>.new()
let v = Vec<Int>.withCapacity(1000)
| Method | Return | Description |
|---|---|---|
push(value: T) | Void | Append element |
pop() | T | Remove last |
get(index: Int) | T | Get by index |
set(index: Int, value: T) | Void | Set by index |
len() | Int | Length |
isEmpty() | Bool | Check empty |
capacity() | Int | Total capacity |
clear() | Void | Remove all elements |
reverse() | Void | Reverse in place |
Robin-hood hashing hash map. Iteration order is non-deterministic.
Generic keys in the source fallback hash through their stable string form, so supported primitive and string keys no longer collapse into a single bucket. For string-heavy workloads, StringHashMap<V> still avoids generic conversion overhead and uses byte-wise hashing directly.
import collections.hash_map
let map = HashMap<String, Int>()
let map = HashMap<String, Int>.withCapacity(100)
| Method | Return | Description |
|---|---|---|
insert(key: K, value: V) | Void | Insert or update |
get(key: K) | Option<V> | Lookup by key |
getOrDefault(key: K, defaultValue: V) | V | Lookup without allocating an Option result |
containsKey(key: K) | Bool | Probe without allocating an Option result |
getUnchecked(key: K) | V | Direct lookup for hot paths after containsKey; missing keys are caller error |
remove(key: K) | Option<V> | Remove by key |
len() | Int | Number of entries |
isEmpty() | Bool | Check empty |
clear() | Void | Remove all entries |
4 variants per operation (key types: int_int, int_str, str_int, str_str):
| Function | Description |
|---|---|
hashmap_new_*() | Create new map |
hashmap_new_*_with_capacity(cap) | Create with capacity |
hashmap_insert_*(map, key, val) | Insert |
hashmap_get_*(map, key) | Lookup |
hashmap_getUnchecked_*(map, key) | Direct lookup without constructing an Option wrapper |
hashmap_remove_*(map, key) | Remove |
hashmap_clear_*(map) | Clear all entries |
hashmap_size_*(map) | Get size |
var scores = HashMap<String, Int>()
scores.insert("Alice", 95)
scores.insert("Bob", 87)
scores.insert("Charlie", 92)
let alice = scores.get("Alice")
if alice.isSome() {
println("Alice's score: {alice.unwrap()}")
}
Ordered map based on B-tree. Keys are kept sorted.
import collections.btree_map
Same interface as HashMap, but with ordered iteration.
4 variants (int_int, int_str, str_int, str_str):
| Function | Description |
|---|---|
btreemap_new_*() | Create new map |
btreemap_insert_*(map, key, val) | Insert (maintains order) |
btreemap_get_*(map, key) | Lookup |
btreemap_remove_*(map, key) | Remove |
btreemap_clear_*(map) | Clear |
btreemap_size_*(map) | Size |
Unordered set backed by HashMap<T, Unit>.
import collections.hashset
Ordered set backed by BTreeMap<T, Unit>.
import collections.btree_set
Doubly-linked list.
import collections.linked_list
| Method | Return | Description |
|---|---|---|
push_front(value: T) | Void | Add to front |
push_back(value: T) | Void | Add to back |
pop_front() | T | Remove from front |
pop_back() | T | Remove from back |
len() | Int | Length |
2 variants (int, str):
| Function | Description |
|---|---|
linkedlist_new_*() | Create new list |
linkedlist_push_front_*(list, val) | Push front |
linkedlist_push_back_*(list, val) | Push back |
linkedlist_pop_front_*(list) | Pop front |
linkedlist_pop_back_*(list) | Pop back |
linkedlist_size_*(list) | Size |
Double-ended queue with O(1) front/back operations.
import collections.vecdeque
collections/vecdeque currently exposes IntVecDeque for integer queues.
Inline-storage vector that avoids heap allocation for small sizes:
let sv = seen_small_vec_new(8) // inline capacity of 8
seen_small_vec_push_i64(sv, 42)
let val = seen_small_vec_get_i64(sv, 0)
let len = seen_small_vec_length(sv)
seen_small_vec_clear(sv)
Falls back to heap when inline capacity is exceeded.
Optimized HashMap<String, V> with string-specific hashing.
import collections.string_hash_map
Low-level byte storage for binary data. ByteArray and ByteBuffer use compact runtime-backed byte storage and expose Int values at the API boundary.
import collections.byte_buffer
let bytes = ByteBuffer.withCapacity(1024)
bytes.reserve(4096)
bytes.push(255)
bytes.push(256) // stored as 0
let value = bytes.get(0)
| Type | Description |
|---|---|
ByteArray | Compact growable byte array |
ByteBuffer | Convenience wrapper around ByteArray |
Int32Buffer / Int64Buffer | Primitive integer buffer APIs backed by compact runtime storage |
Float32Buffer / Float64Buffer | Primitive floating-point buffer APIs backed by native float/double storage |
| Method | Return | Description |
|---|---|---|
capacity() | Int | Current allocated capacity |
tryReserve(requiredCapacity) | Bool | Grow backing storage without aborting on allocation failure |
reserve(requiredCapacity) | Void | Grow backing storage or panic with a Seen diagnostic |
push(value: Int) | Void | Append byte, masked to 0..255 |
append(other) | Void | Append another byte buffer |
get(index: Int) | Int | Read byte |
set(index: Int, value: Int) | Void | Write byte |
slice(start: Int, end: Int) | same type | Copy a byte range |
reverse() | Void | Reverse in place |
fill(value: Int) | Void | Fill existing bytes |
toArray() / toIntArray() | Array<Int> | Convert to integer byte values |
Shared collection algorithms for performance-sensitive integer and floating-point paths.
import collections.algorithms
Module path: collections/algorithms.
| Function / Type | Description |
|---|---|
binarySearchInt(values, needle) | Return matching index or -1 |
lowerBoundInt(values, needle) | First insertion slot not less than needle |
upperBoundInt(values, needle) | First insertion slot greater than needle |
unstableSortInt(values) | In-place introsort with insertion sort for small partitions and a heapsort depth fallback |
stableSortInt(values) | Stable sorted copy |
radixSortInt(values) | Signed integer radix sort that preserves negative/positive ordering |
IntPriorityQueue.min() / .max() | Binary heap priority queues |
binarySearchFloat(values, needle) | Return matching float index or -1 |
lowerBoundFloat(values, needle) | First float insertion slot not less than needle |
upperBoundFloat(values, needle) | First float insertion slot greater than needle |
unstableSortFloat(values) | In-place introsort for Array<Float> |
stableSortFloat(values) | Stable sorted float copy |
FloatPriorityQueue.min() / .max() | Binary heap priority queues for floats |
Compact bit set.
import collections.bit_set
Mutable string buffer used by parser, compiler, and text-heavy runtime code.
import collections.string_buffer
collections/std_string provides StdString, a stdlib wrapper around string operations that need a class-style surface.
Object pool for reusing allocated objects.
import collections.pool