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/heap"
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 |
|---|---|---|
collections |
std/collections |
heap.dodo |
error |
alloc/error |
heap.dodo |
vector |
std/collections/vector |
heap.dodo |
Heap
Struct · Source
Max binary heap. Equal values have unspecified removal order.
pub struct Heap<T, C, A> {
// Private implementation fields omitted.
}
Heap.next
Function · Source
Cursor starts at zero. Each call yields one logical element.
pub fn next(&self, cursor: &mut usize) -> Option<&T> from(self)
Heap.len
Function · Source
pub fn len(&self) -> usize
Heap.capacity
Function · Source
pub fn capacity(&self) -> usize
Heap.peek
Function · Source
pub fn peek(&self) -> Option<&T>
Heap.as_slice
Function · Source
Borrowed heap-order view, not sorted iteration.
pub fn as_slice(&self) -> &[T]
Heap.push
Function · Source
pub fn push(&mut self, value: T) -> void!error.AllocError stores(self, value)
Heap.pop
Function · Source
pub fn pop(&mut self) -> Option<T> from(self.stored)
Heap.clear
Function · Source
pub fn clear(&mut self)
new
Function · Source
SAFETY: allocator must satisfy vector.new’s capability contract.
pub unsafe fn new<T, C, A>(allocator: A, ordering: C) -> Heap<T, C, A> from(allocator, ordering)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.