[][src]Struct contrie::raw::Raw

pub struct Raw<C: Config, S> { /* fields omitted */ }

The raw hash trie data structure.

This provides the low level data structure. It does provide the lock-free operations on some values. On the other hand, it does not provide user friendly interface. It is designed to separate the single implementation of the core algorithm and provide a way to wrap it into different interfaces for different use cases.

It, however, can be used to fulfill some less common uses.

The types stored inside and general behaviour is described by the Config type parameter and can be customized using that.

As a general rule, this data structure takes the crossbeam_epoch Guard and returns borrowed data whenever appropriate. This allows cheaper manipulation if necessary or grouping multiple operations together. Note than even methods that would return owned values in single-threaded case (eg. insert and remove return borrowed values. This is because in concurrent situation some other thread might still be accessing them. They are scheduled for destruction once the epoch ends.

For details of the internal implementation and correctness arguments, see the comments in source code (they probably don't belong into API documentation).

Methods

impl<C, S> Raw<C, S> where
    C: Config,
    S: BuildHasher
[src]

pub fn with_hasher(hash_builder: S) -> Self[src]

Constructs an empty instance from the given hasher.

pub fn insert<'s, 'p, 'r>(
    &'s self,
    payload: C::Payload,
    pin: &'p Guard
) -> Option<&'r C::Payload> where
    's: 'r,
    'p: 'r, 
[src]

Inserts a new value, replacing and returning any previously held value.

pub fn get<'r, 's, 'p, Q: ?Sized>(
    &'s self,
    key: &Q,
    pin: &'p Guard
) -> Option<&'r C::Payload> where
    's: 'r,
    'p: 's,
    Q: Eq + Hash,
    C::Key: Borrow<Q>, 
[src]

Looks up a value.

pub fn get_or_insert_with<'s, 'p, 'r, F>(
    &'s self,
    key: C::Key,
    create: F,
    pin: &'p Guard
) -> ExistingOrNew<&'r C::Payload> where
    's: 'r,
    'p: 'r,
    F: FnOnce(C::Key) -> C::Payload
[src]

Looks up a value or create (and insert) a new one.

Either way, returns the value.

pub fn remove<'r, 's, 'p, Q: ?Sized>(
    &'s self,
    key: &Q,
    pin: &'p Guard
) -> Option<&'r C::Payload> where
    's: 'r,
    'p: 'r,
    Q: Eq + Hash,
    C::Key: Borrow<Q>, 
[src]

Removes a value identified by the key from the trie, returning it if it was found.

impl<C: Config, S> Raw<C, S>[src]

pub fn is_empty(&self) -> bool[src]

Checks for emptiness.

pub fn hash_builder(&self) -> &S[src]

Access to the hash builder.

Trait Implementations

impl<C: Config, S> Drop for Raw<C, S>[src]

Auto Trait Implementations

impl<C, S> Unpin for Raw<C, S> where
    S: Unpin,
    <C as Config>::Payload: Unpin

impl<C, S> Send for Raw<C, S> where
    S: Send,
    <C as Config>::Payload: Send

impl<C, S> Sync for Raw<C, S> where
    S: Sync,
    <C as Config>::Payload: Sync

impl<C, S> UnwindSafe for Raw<C, S> where
    S: UnwindSafe,
    <C as Config>::Payload: UnwindSafe

impl<C, S> RefUnwindSafe for Raw<C, S> where
    S: RefUnwindSafe,
    <C as Config>::Payload: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]