Struct ordermap::Pos

source ·
pub(crate) struct Pos {
    pub(crate) index: u64,
}
Expand description

Pos is stored in the indices array and it points to the index of a Bucket in self.entries.

Pos can be interpreted either as a 64-bit index, or as a 32-bit index and a 32-bit hash.

Storing the truncated hash next to the index saves loading the hash from the entry, increasing the cache efficiency.

Note that the lower 32 bits of the hash is enough to compute desired position and probe distance in a hash map with less than 2**32 buckets.

The OrderMap will simply query its current raw capacity to see what its current size class is, and dispatch to the 32-bit or 64-bit lookup code as appropriate. Only the growth code needs some extra logic to handle the transition from one class to another

Fields§

§index: u64

Implementations§

source§

impl Pos

source

pub(crate) fn none() -> Self

source

pub(crate) fn is_none(&self) -> bool

source

pub(crate) fn pos(&self) -> Option<usize>

Return the index part of the Pos value inside Some(_) if the position is not none, otherwise return None.

source

pub(crate) fn set_pos<Sz>(&mut self, i: usize)
where Sz: Size,

Set the index part of the Pos value to i

source

pub(crate) fn with_hash<Sz>(i: usize, hash: HashValue) -> Self
where Sz: Size,

source

pub(crate) fn resolve<Sz>(&self) -> Option<(usize, ShortHashProxy<Sz>)>
where Sz: Size,

“Resolve” the Pos into a combination of its index value and a proxy value to the hash (whether it contains the hash or not depends on the size class of the hash map).

source

pub(crate) fn resolve_existing_index<Sz>(&self) -> usize
where Sz: Size,

Like resolve, but the Pos must be non-none. Return its index.

Trait Implementations§

source§

impl Clone for Pos

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 Debug for Pos

source§

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

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

impl Copy for Pos

Auto Trait Implementations§

§

impl Freeze for Pos

§

impl RefUnwindSafe for Pos

§

impl Send for Pos

§

impl Sync for Pos

§

impl Unpin for Pos

§

impl UnwindSafe for Pos

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

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 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.