[go: up one dir, main page]

Struct Raw

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

Source

pub fn with_hasher(hash_builder: S) -> Self

Constructs an empty instance from the given hasher.

Source

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.

Source

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

Looks up a value.

Source

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 F: FnOnce(C::Key) -> C::Payload, 's: 'r, 'p: 'r,

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

Either way, returns the value.

Source

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

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

Source§

impl<C: Config, S> Raw<C, S>

Source

pub fn is_empty(&self) -> bool

Checks for emptiness.

Source

pub fn hash_builder(&self) -> &S

Access to the hash builder.

Trait Implementations§

Source§

impl<C: Config, S> Drop for Raw<C, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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>
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> Unpin for Raw<C, S>
where S: Unpin, <C as Config>::Payload: Unpin,

§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.