pub struct Raw<C: Config, S> { /* private fields */ }Expand description
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).
Implementations§
Source§impl<C, S> Raw<C, S>where
C: Config,
S: BuildHasher,
impl<C, S> Raw<C, S>where
C: Config,
S: BuildHasher,
Sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Constructs an empty instance from the given hasher.
Sourcepub fn insert<'s, 'p, 'r>(
&'s self,
payload: C::Payload,
pin: &'p Guard,
) -> Option<&'r C::Payload>where
's: 'r,
'p: 'r,
pub fn insert<'s, 'p, 'r>(
&'s self,
payload: C::Payload,
pin: &'p Guard,
) -> Option<&'r C::Payload>where
's: 'r,
'p: 'r,
Inserts a new value, replacing and returning any previously held value.
Sourcepub fn get<'r, 's, 'p, Q>(
&'s self,
key: &Q,
pin: &'p Guard,
) -> Option<&'r C::Payload>
pub fn get<'r, 's, 'p, Q>( &'s self, key: &Q, pin: &'p Guard, ) -> Option<&'r C::Payload>
Looks up a value.
Sourcepub fn get_or_insert_with<'s, 'p, 'r, F>(
&'s self,
key: C::Key,
create: F,
pin: &'p Guard,
) -> ExistingOrNew<&'r C::Payload>
pub fn get_or_insert_with<'s, 'p, 'r, F>( &'s self, key: C::Key, create: F, pin: &'p Guard, ) -> ExistingOrNew<&'r C::Payload>
Looks up a value or create (and insert) a new one.
Either way, returns the value.
Trait Implementations§
Auto Trait Implementations§
impl<C, S> !Freeze for Raw<C, S>
impl<C, S> RefUnwindSafe for Raw<C, S>
impl<C, S> Send for Raw<C, S>
impl<C, S> Sync for Raw<C, S>
impl<C, S> Unpin for Raw<C, S>
impl<C, S> UnwindSafe for Raw<C, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more