Module coil-stdlib

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#

ModuleDescription
collections::bitsetBitSet: a compact set of small non-negative integers.
collections::dequeVecDeque: a double-ended queue with fast push and pop at both ends.
collections::listList: a singly-linked list.
collections::mapHashMap: a hash map from keys to values.
collections::setHashSet: a set of unique values.
collections::treeTreeMap: a map that keeps its keys in sorted order.
collections::vecFunctional helpers for Vec: map, filter, fold, chunks, windows, partition, search.

Functions#

NameDescription
sortReturns a sorted copy of arr, in ascending order.
sort_byReturns a copy of arr sorted by the value key gives each element, in ascending order.
reverseReturns a copy of arr in reverse order.
collect_intsReturns the values of the range a..b as a Vec<int>.
collect_ints_inclusiveReturns the values of the inclusive range a..=b as a Vec<int>.
↑ ↓ navigate ↵ open