Skip to main content

OrderedTable

Struct OrderedTable 

Source
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>,

Source

pub fn new(equivalence: E) -> Self

Construct an empty table using equivalence for all key lookup.

Source

pub fn len(&self) -> usize

Return the number of live entries.

Source

pub fn is_empty(&self) -> bool

Return whether the table contains no live entries.

Source

pub fn get(&self, key: &K) -> Option<V>
where V: Clone,

Return a clone of the value for the equivalent key, if present.

Source

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.

Source

pub fn remove(&self, key: &K) -> Option<V>

Delete an equivalent key, returning its value when present.

Source

pub fn iter(&self) -> OrderedTableIter<K, V>

Create a live insertion-order iterator.

Source

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.

Trait Implementations§

Source§

impl<K: Debug, V: Debug, E: Debug> Debug for OrderedTable<K, V, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V, E> !RefUnwindSafe for OrderedTable<K, V, E>

§

impl<K, V, E> !Send for OrderedTable<K, V, E>

§

impl<K, V, E> !Sync for OrderedTable<K, V, E>

§

impl<K, V, E> !UnwindSafe for OrderedTable<K, V, E>

§

impl<K, V, E> Freeze for OrderedTable<K, V, E>
where E: Freeze,

§

impl<K, V, E> Unpin for OrderedTable<K, V, E>
where E: Unpin,

§

impl<K, V, E> UnsafeUnpin for OrderedTable<K, V, E>
where E: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.