docs

core::collections

API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.

List / Dict / Set / Slice, Deque, BinaryHeap, SortedDict / SortedSet, and the frozen (read-only, Sync) List / Dict / Set.

Each collection is a small handle struct over GC buffers (raw): copying the handle shares the collection, so the mutating methods take self (not ref self: the handle is what they change). The types are re-exported here: use core::collections::List.

Modules

  • broadcast the element-wise dot operators on List<T>: List op List (same length, else a panic), List op T and T op List (the scalar applies to every element).
  • deque Deque<T>, a growable ring buffer with O(1) push and pop at both ends.
  • dict Dict<K, V, S>, a hash map hashing with S (the process-keyed RandomState by default), compact: entries are appended to dense key / value / hash arrays, and a power-of-two index of linear-probed slots maps a hash to its entry.
  • frozen FrozenList, FrozenDict and FrozenSet: a collection that no one can change any more, shared between threads without a lock and without a copy.
  • heap BinaryHeap<T>, a priority queue over a List laid out as an implicit binary tree.
  • list List<T>, a growable array: one object holding the length, the capacity and the current element buffer, swapped for a bigger one on growth.
  • set Set<T, S>, a hash set over Dict<T, bool, S>, so it iterates in insertion order.
  • slice Slice<T>, a zero-copy view; element i is buf[start + i * stride], and the view keeps its buffer alive.
  • sorted SortedDict<K, V> and SortedSet<T>: ordered by K: Ord, kept in a B-tree.

Re-exports

deque::{Deque, DequeIter}Source

pub use deque::{Deque, DequeIter}
  • Deque A growable ring buffer with O(1) push and pop at both ends.
  • DequeIter Front to back.

dict::{Dict, Entry, Keys, Values, DictIter}Source

pub use dict::{Dict, Entry, Keys, Values, DictIter}
  • Dict S builds the hashers (RandomState: the process key).
  • Entry d.entry(k): read or fill one key's slot.
  • Keys What d.keys() returns: the keys, in insertion order.
  • Values What d.values() returns: the values, in insertion order.
  • DictIter What d.iter() returns: (key, value) pairs, in insertion order.

frozen::{FrozenDict, FrozenList, FrozenSet}Source

pub use frozen::{FrozenDict, FrozenList, FrozenSet}
  • FrozenDict A dict that never changes: Sync, so threads share one without a lock.
  • FrozenList A list that never changes: Sync, so threads share one without a lock (a par closure may capture it, a static may hold it, a hand-off leaves it shared).
  • FrozenSet A set that never changes: Sync, so threads share one without a lock.

heap::{BinaryHeap, HeapIter}Source

pub use heap::{BinaryHeap, HeapIter}
  • BinaryHeap A priority queue: new() pops the greatest item first, by_ordering(cmp) the greatest by cmp.
  • HeapIter The items of a heap, in no particular order.

list::{List, ListIter, ListIntoIter}Source

pub use list::{List, ListIter, ListIntoIter}
  • List A growable array; copies share one buffer.
  • ListIter xs.iter() / for x in xs: walks a list front to back.
  • ListIntoIter What xs.into_iter() returns: the same walk as iter.

set::{Set, SetIter}Source

pub use set::{Set, SetIter}
  • Set S builds the hashers (RandomState: the process key).
  • SetIter The members of a set, in insertion order.

slice::{ChunksMut, Slice, SliceIter, SliceMut, SliceMutIter}Source

pub use slice::{ChunksMut, Slice, SliceIter, SliceMut, SliceMutIter}
  • ChunksMut xs.chunks_mut(size): each chunk is a writable view of its own part of the list, no copy.
  • Slice A zero-copy view of a buffer: element i is buf[start + i * stride].
  • SliceIter s.iter() / for x in s, in view order.
  • SliceMut A writable view of a list's elements, like Rust's &mut [T]: s[i] = x writes the list.
  • SliceMutIter s.iter() / for x in s: checks the view on every step.

sorted::{KeyRange, SortedDict, SortedIter, SortedKeys, SortedSet, SortedValues}Source

pub use sorted::{KeyRange, SortedDict, SortedIter, SortedKeys, SortedSet, SortedValues}
  • KeyRange The bounds of a key range: a..b, a..=b, a.., ..b, ..=b and .. implement it, so d.range(3..7) takes any of them.
  • SortedDict A map ordered by key.
  • SortedIter The entries of a SortedDict in key order (or reversed), within a range.
  • SortedKeys The keys of a SortedDict in order.
  • SortedSet A set ordered by T: Ord, kept in a B-tree.
  • SortedValues The values of a SortedDict in key order.