pub struct OrderedTable<K, V, E> { /* private fields */ }Expand description
Mutable insertion-ordered table with caller-defined key equivalence.
Replacement retains an entry’s logical position. Deletion leaves a tombstone, and reinserting an equivalent key appends a new entry. Iterators are live rather than snapshots: they skip entries deleted before visitation and observe entries appended before iteration ends.
Implementations§
Source§impl<K, V, E> OrderedTable<K, V, E>where
E: KeyEquivalence<K>,
impl<K, V, E> OrderedTable<K, V, E>where
E: KeyEquivalence<K>,
Sourcepub fn new(equivalence: E) -> Self
pub fn new(equivalence: E) -> Self
Construct an empty table using equivalence for all key lookup.
Sourcepub fn get(&self, key: &K) -> Option<V>where
V: Clone,
pub fn get(&self, key: &K) -> Option<V>where
V: Clone,
Return a clone of the value for the equivalent key, if present.
Sourcepub fn insert(&self, key: K, value: V) -> Option<V>
pub fn insert(&self, key: K, value: V) -> Option<V>
Insert a key/value pair, returning the replaced value when present.
An equivalent live key is replaced in place. A key equivalent only to a tombstone is a new insertion and therefore appears at the end.
Sourcepub fn remove(&self, key: &K) -> Option<V>
pub fn remove(&self, key: &K) -> Option<V>
Delete an equivalent key, returning its value when present.
Sourcepub fn iter(&self) -> OrderedTableIter<K, V> ⓘ
pub fn iter(&self) -> OrderedTableIter<K, V> ⓘ
Create a live insertion-order iterator.
Sourcepub fn compact(&self, max_work: usize) -> CompactionResult
pub fn compact(&self, max_work: usize) -> CompactionResult
Compact tombstones when doing so is position-safe and within max_work.
Work is bounded by the current slot count. The operation is all-or-none: it does not begin unless that count fits the supplied budget, and it never runs while an iterator holds a position in this table.