Skip to content

std::collections

Status: experimental

Built-in container types.

API details and source

The implementation source contains the complete declarations and implementation notes. The table below lists canonical Gossamer call signatures; every item name links directly to its implementation file.

Item Canonical signature or declaration Description
BTreeMap type BTreeMap Ordered map.
HashMap type HashMap Hash map backed by the swiss-table layout.
HashSet type HashSet Unordered set built on top of HashMap.
Vec type Vec Growable contiguous sequence.
VecDeque type VecDeque Double-ended queue backed by a ring buffer.
len fn len(xs: Deque<i64>) -> i64 Element count.
peek_back fn peek_back(xs: Deque<i64>) -> i64 Back element, or 0 if empty.
peek_front fn peek_front(xs: Deque<i64>) -> i64 Front element, or 0 if empty.
pop_back fn pop_back(xs: Deque<i64>) -> Deque<i64> Drop the back.
pop_front fn pop_front(xs: Deque<i64>) -> Deque<i64> Drop the front.
push_back fn push_back(xs: Deque<i64>, value: i64) -> Deque<i64> Append to the back.
push_front fn push_front(xs: Deque<i64>, value: i64) -> Deque<i64> Prepend to the front.
len fn len(xs: Heap<i64>) -> i64 Element count.
peek fn peek(xs: Heap<i64>) -> i64 Smallest element of the heap, or 0 if empty.
pop fn pop(xs: Heap<i64>) -> Heap<i64> Drop the root from the heap; returns the new heap (use peek first to read the value).
push fn push(xs: Heap<i64>, value: i64) -> Heap<i64> Push an i64 onto the min-heap; returns the new heap.
contains_key fn contains_key(map: OrderedMap<String, i64>, key: String) -> bool Key-membership test.
get fn get(map: OrderedMap<String, i64>, key: String) -> Option<i64> Lookup; returns 0 if absent.
insert fn insert(map: OrderedMap<String, i64>, key: String, value: i64) -> OrderedMap<String, i64> Set key => value.
len fn len(map: OrderedMap<String, i64>) -> i64 Pair count.
remove fn remove(map: OrderedMap<String, i64>, key: String) -> OrderedMap<String, i64> Remove a key.
contains fn contains(xs: OrderedSet<i64>, value: i64) -> bool Membership test.
insert fn insert(xs: OrderedSet<i64>, value: i64) -> OrderedSet<i64> Insert (sorted, no duplicates).
len fn len(xs: OrderedSet<i64>) -> i64 Element count.
remove fn remove(xs: OrderedSet<i64>, value: i64) -> OrderedSet<i64> Remove a value.
contains fn contains(xs: Vec<i64>, value: i64) -> bool Return true iff value is present.
index_of fn index_of(xs: Vec<i64>, value: i64) -> Option<i64> Return the index of value, or -1.
insert fn insert(xs: Vec<i64>, value: i64) -> Vec<i64> Insert at the unique sorted position.
len fn len(xs: Vec<i64>) -> i64 Element count.
peek_max fn peek_max(xs: Vec<i64>) -> i64 Largest element, or 0.
peek_min fn peek_min(xs: Vec<i64>) -> i64 Smallest element, or 0.
remove_at fn remove_at(xs: Vec<i64>, index: i64) -> Vec<i64> Remove the element at index i.
len fn len(xs: Queue<i64>) -> i64 Element count.
peek fn peek(xs: Queue<i64>) -> i64 Front element, or 0 if empty.
pop fn pop(xs: Queue<i64>) -> Queue<i64> Drop the front element; returns the new queue.
push fn push(xs: Queue<i64>, value: i64) -> Queue<i64> Append an i64 to the back; returns the new queue.
len fn len(xs: Stack<i64>) -> i64 Element count.
peek fn peek(xs: Stack<i64>) -> i64 Top element, or 0 if empty.
pop fn pop(xs: Stack<i64>) -> Stack<i64> Drop the top; returns the new stack.
push fn push(xs: Stack<i64>, value: i64) -> Stack<i64> Push an i64 onto the top; returns the new stack.