collections
The collection types live in submodules: HashMap, HashSet, TreeMap, VecDeque, List and BitSet. Vec itself is in the prelude; its functional helpers (map, filter, fold, …) are in collections::vec.
Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.
Import what you use (use path::* is not allowed):
use collections::{sort, sort_by};
Modules#
| Module | Description |
|---|---|
collections::bitset | BitSet: a compact set of small non-negative integers. |
collections::deque | VecDeque: a double-ended queue with fast push and pop at both ends. |
collections::list | List: a singly-linked list. |
collections::map | HashMap: a hash map from keys to values. |
collections::set | HashSet: a set of unique values. |
collections::tree | TreeMap: a map that keeps its keys in sorted order. |
collections::vec | Functional helpers for Vec: map, filter, fold, chunks, windows, partition, search. |
Functions#
| Name | Description |
|---|---|
sort | Returns a sorted copy of arr, in ascending order. |
sort_by | Returns a copy of arr sorted by the value key gives each element, in ascending order. |
reverse | Returns a copy of arr in reverse order. |
collect_ints | Returns the values of the range a..b as a Vec<int>. |
collect_ints_inclusive | Returns the values of the inclusive range a..=b as a Vec<int>. |