API referencestd/collections

std/collections

Public declarations, types, methods, and source contracts for std/collections.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/collections"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
mem core/mem collections.dodo
ptr core/ptr collections.dodo

I32

Struct · Source

Policies use statically resolved methods; the closure forms at the end take a closure reference instead. compare(&T,&T) returns negative/zero/positive; equal(&T,&T) returns bool.

pub struct I32 {

}

I32.compare

Function · Source

pub fn compare(&self, a: &i32, b: &i32) -> i32

I32.equal

Function · Source

pub fn equal(&self, a: &i32, b: &i32) -> bool

U64

Struct · Source

pub struct U64 {

}

U64.compare

Function · Source

pub fn compare(&self, a: &u64, b: &u64) -> i32

U64.equal

Function · Source

pub fn equal(&self, a: &u64, b: &u64) -> bool

CapacityError

Enum · Source

pub enum CapacityError {
    Full, OutOfBounds
}

swap

Function · Source

Checked indices, ownership-moving exchange, no destruction. O(1). The mem.init gate explicitly rejects borrow/Result-bearing element types.

pub fn swap<T>(data: &mut[T], a: usize, b: usize) -> bool

find

Function · Source

pub fn find<T, E>(data: &[T], needle: &T, equality: &E) -> Option<usize>

equal

Function · Source

pub fn equal<T, E>(a: &[T], b: &[T], equality: &E) -> bool

compare

Function · Source

pub fn compare<T, C>(a: &[T], b: &[T], ordering: &C) -> i32

lower_bound

Function · Source

First element >= needle; insertion position on an empty slice is zero.

pub fn lower_bound<T, C>(data: &[T], needle: &T, ordering: &C) -> usize

upper_bound

Function · Source

pub fn upper_bound<T, C>(data: &[T], needle: &T, ordering: &C) -> usize

Function · Source

pub fn binary_search<T, C>(data: &[T], needle: &T, ordering: &C) -> Option<usize>

is_sorted

Function · Source

pub fn is_sorted<T, C>(data: &[T], ordering: &C) -> bool

sort

Function · Source

In-place heapsort: O(n log n) worst case, O(1) storage, unstable.

pub fn sort<T, C>(data: &mut[T], ordering: &C)

stable_sort

Function · Source

Stable insertion sort: O(n²) worst case; O(n) for sorted input.

pub fn stable_sort<T, C>(data: &mut[T], ordering: &C)

partition

Function · Source

Predicate provides test(&T)->bool. True values precede false values. Returns the boundary, O(n) time/O(1) storage, unstable.

pub fn partition<T, P>(data: &mut[T], predicate: &P) -> usize

sort_by

Function · Source

In-place heapsort: O(n log n) worst case, O(1) storage, unstable.

pub fn sort_by<T>(data: &mut[T], compare: &mut dyn fn(&T, &T) -> i32)

stable_sort_by

Function · Source

Stable insertion sort: O(n²) worst case; O(n) for sorted input.

pub fn stable_sort_by<T>(data: &mut[T], compare: &mut dyn fn(&T, &T) -> i32)

is_sorted_by

Function · Source

pub fn is_sorted_by<T>(data: &[T], compare: &mut dyn fn(&T, &T) -> i32) -> bool

binary_search_by

Function · Source

probe(element) compares one element with the sought key: negative when the element sorts before it, zero when equal. Returns the first equal index.

pub fn binary_search_by<T>(data: &[T], probe: &mut dyn fn(&T) -> i32) -> Option<usize>

partition_by

Function · Source

True values precede false values. Returns the boundary; unstable.

pub fn partition_by<T>(data: &mut[T], test: &mut dyn fn(&T) -> bool) -> usize

position

Function · Source

The index of the first element for which test is true.

pub fn position<T>(data: &[T], test: &mut dyn fn(&T) -> bool) -> Option<usize>

any

Function · Source

Stops at the first element for which test is true.

pub fn any<T>(data: &[T], test: &mut dyn fn(&T) -> bool) -> bool

all

Function · Source

Stops at the first element for which test is false.

pub fn all<T>(data: &[T], test: &mut dyn fn(&T) -> bool) -> bool

count

Function · Source

pub fn count<T>(data: &[T], test: &mut dyn fn(&T) -> bool) -> usize

for_each

Function · Source

pub fn for_each<T>(data: &[T], visit: &mut dyn fn(&T))

for_each_mut

Function · Source

pub fn for_each_mut<T>(data: &mut[T], visit: &mut dyn fn(&mut T))

map

Function · Source

Writes transform(input[i]) to output[i], replacing (and destroying) the old value, for each index both slices have. Returns that count.

pub fn map<T, U>(input: &[T], output: &mut[U], transform: &mut dyn fn(&T) -> U) -> usize

fold

Function · Source

Combines the elements from first to last, starting with initial.

pub fn fold<T, A>(data: &[T], initial: A, combine: &mut dyn fn(A, &T) -> A) -> A

Search every guide, reference page, and API declaration.