pub struct BudgetedSharedMap<K, V> { /* private fields */ }Expand description
A persistent ordered map with logarithmic lookup and insertion. Cloning shares a root without copying entries or allocating. Updates reserve the complete insertion before mutation, reuse unique nodes and copy shared paths; unchanged entries and subtrees keep their original reservations until their last root is dropped. Keys and values retain their separately owned payloads.
Implementations§
pub fn new(memory: &MemoryBudget) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn budget(&self) -> &MemoryBudget
Sourcepub fn snapshot(&self) -> BudgetedSharedMapSnapshot<K, V>
pub fn snapshot(&self) -> BudgetedSharedMapSnapshot<K, V>
Retain this immutable root without another mutable allowance handle or any allocation.
Sourcepub fn restore(&mut self, snapshot: &BudgetedSharedMapSnapshot<K, V>)
pub fn restore(&mut self, snapshot: &BudgetedSharedMapSnapshot<K, V>)
Restore a retained root without allocating. Panics before mutation if a nonempty root belongs to another allowance; empty roots own no allocations and can be restored into any allowance.
pub fn iter(&self) -> BudgetedSharedMapIter<'_, K, V> ⓘ
Sourcepub fn last_before<Q: Ord + ?Sized>(&self, end: Bound<&Q>) -> Option<(&K, &V)>where
K: Borrow<Q>,
pub fn last_before<Q: Ord + ?Sized>(&self, end: Bound<&Q>) -> Option<(&K, &V)>where
K: Borrow<Q>,
Select the greatest entry at an upper bound in logarithmic time, without allocating or traversing preceding entries.
pub fn get<Q: Ord + ?Sized>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Sourcepub fn with_insert(&self, key: K, value: V) -> Result<Self, MemoryError>
pub fn with_insert(&self, key: K, value: V) -> Result<Self, MemoryError>
Return a new root containing the supplied key and value, leaving this root unchanged even if reservation fails. Matching keys are replaced together with their values; neither type needs to implement Clone.
Sourcepub fn try_insert(&mut self, key: K, value: V) -> Result<(), MemoryError>
pub fn try_insert(&mut self, key: K, value: V) -> Result<(), MemoryError>
Reserve the complete insertion before changing this root, reusing unique nodes and copying only shared paths. Reservation failure preserves this root; existing clones remain unchanged. Matching keys and values are replaced together without requiring Clone.
Sourcepub fn range_from<Q: Ord + ?Sized>(
&self,
start: Bound<&Q>,
) -> BudgetedSharedMapIter<'_, K, V> ⓘwhere
K: Borrow<Q>,
pub fn range_from<Q: Ord + ?Sized>(
&self,
start: Bound<&Q>,
) -> BudgetedSharedMapIter<'_, K, V> ⓘwhere
K: Borrow<Q>,
Visit keys in order, seeking the lower bound without traversing earlier entries or allocating a traversal buffer.