pub struct AugDict<K, A, V> { /* private fields */ }
Expand description

Typed augmented dictionary with fixed length keys.

TLB scheme

ahm_edge#_ {n:#} {V:Type} {A:Type} {l:#} {m:#}
  label:(HmLabel ~l n) {n = (~m) + l}
  node:(HashmapAugNode m V A) = HashmapAug n V A;

ahmn_leaf#_ {V:Type} {A:Type} extra:A value:V = HashmapAugNode 0 V A;
ahmn_fork#_ {n:#} {V:Type} {A:Type} left:^(HashmapAug n V A)
  right:^(HashmapAug n V A) extra:A = HashmapAugNode (n + 1) V A;

ahme_empty$0 {n:#} {V:Type} {A:Type} extra:A = HashmapAugE n V A;
ahme_root$1 {n:#} {V:Type} {A:Type} root:^(HashmapAug n V A) extra:A = HashmapAugE n V A;

Implementations§

source§

impl<K, A: Default, V> AugDict<K, A, V>

source

pub fn new() -> Self

Creates an empty dictionary

source§

impl<K, A, V> AugDict<K, A, V>

source

pub const fn is_empty(&self) -> bool

Returns true if the dictionary contains no elements.

source

pub const fn dict(&self) -> &Dict<K, (A, V)>

Returns the underlying dictionary.

source

pub const fn root_extra(&self) -> &A

Returns the root augmented value.

source§

impl<K, A, V> AugDict<K, A, V>where K: Store + DictKey,

source

pub fn contains_key<Q>(&self, key: Q) -> Result<bool, Error>where Q: Borrow<K>,

Returns true if the dictionary contains a value for the specified key.

source§

impl<K, A, V> AugDict<K, A, V>where K: Store + DictKey,

source

pub fn get<'a: 'b, 'b, Q>(&'a self, key: Q) -> Result<Option<(A, V)>, Error>where Q: Borrow<K> + 'b, (A, V): Load<'a>,

Returns the value corresponding to the key.

Key is serialized using the default finalizer.

source§

impl<K, A, V> AugDict<K, A, V>where K: DictKey,

source

pub fn iter<'a>(&'a self) -> AugIter<'_, K, A, V> where V: Load<'a>,

Gets an iterator over the entries of the dictionary, sorted by key. The iterator element type is Result<(K, A, V)>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source

pub fn keys(&self) -> Keys<'_, K>

Gets an iterator over the keys of the dictionary, in sorted order. The iterator element type is Result<K>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values if you don’t need keys from an iterator.

source§

impl<K, A, V> AugDict<K, A, V>where K: DictKey,

source

pub fn values<'a>(&'a self) -> Values<'a, (A, V)> where V: Load<'a>,

Gets an iterator over the augmented values of the dictionary, in order by key. The iterator element type is Result<V>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

source§

impl<K, A, V> AugDict<K, A, V>where K: Store + DictKey,

source

pub fn get_ext<'a: 'b, 'b, Q>( &'a self, key: Q, finalizer: &mut dyn Finalizer ) -> Result<Option<(A, V)>, Error>where Q: Borrow<K> + 'b, A: Load<'a>, V: Load<'a>,

Returns the augmented value corresponding to the key.

Key is serialized using the provided finalizer.

source

pub fn raw_iter(&self) -> RawIter<'_>

Gets an iterator over the raw entries of the dictionary, sorted by key. The iterator element type is Result<(CellBuilder, CellSlice)>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source

pub fn raw_keys(&self) -> RawKeys<'_>

Gets an iterator over the raw keys of the dictionary, in sorted order. The iterator element type is Result<CellBuilder>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Performance

In the current implementation, iterating over dictionary builds a key for each element. Use values or raw_values if you don’t need keys from an iterator.

source§

impl<K, A, V> AugDict<K, A, V>where K: DictKey,

source

pub fn raw_values(&self) -> RawValues<'_>

Gets an iterator over the raw values of the dictionary, in order by key. The iterator element type is Result<CellSlice>.

If the dictionary is invalid, finishes after the first invalid element, returning an error.

Trait Implementations§

source§

impl<K, A: Clone, V> Clone for AugDict<K, A, V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K, A: Debug, V> Debug for AugDict<K, A, V>

source§

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

Formats the value using the given formatter. Read more
source§

impl<K, A: Default, V> Default for AugDict<K, A, V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'a, K, A: Load<'a>, V> Load<'a> for AugDict<K, A, V>

source§

fn load_from(slice: &mut CellSlice<'a>) -> Result<Self, Error>

Tries to load itself from a cell slice.
source§

impl<K, A: PartialEq, V> PartialEq<AugDict<K, A, V>> for AugDict<K, A, V>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, A: Store, V> Store for AugDict<K, A, V>

source§

fn store_into( &self, builder: &mut CellBuilder, finalizer: &mut dyn Finalizer ) -> Result<(), Error>

Tries to store itself into the cell builder.
source§

impl<K, A: Eq, V> Eq for AugDict<K, A, V>

Auto Trait Implementations§

§

impl<K, A, V> !RefUnwindSafe for AugDict<K, A, V>

§

impl<K, A, V> Send for AugDict<K, A, V>where A: Send, K: Send, V: Send,

§

impl<K, A, V> Sync for AugDict<K, A, V>where A: Sync, K: Sync, V: Sync,

§

impl<K, A, V> Unpin for AugDict<K, A, V>where A: Unpin, K: Unpin, V: Unpin,

§

impl<K, A, V> !UnwindSafe for AugDict<K, A, V>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.