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
impl Pos
pub(crate) fn none() -> Self
pub(crate) fn is_none(&self) -> bool
sourcepub(crate) fn pos(&self) -> Option<usize>
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
.
sourcepub(crate) fn set_pos<Sz>(&mut self, i: usize)where
Sz: Size,
pub(crate) fn set_pos<Sz>(&mut self, i: usize)where
Sz: Size,
Set the index part of the Pos value to i
pub(crate) fn with_hash<Sz>(i: usize, hash: HashValue) -> Selfwhere
Sz: Size,
sourcepub(crate) fn resolve<Sz>(&self) -> Option<(usize, ShortHashProxy<Sz>)>where
Sz: Size,
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).
sourcepub(crate) fn resolve_existing_index<Sz>(&self) -> usizewhere
Sz: Size,
pub(crate) fn resolve_existing_index<Sz>(&self) -> usizewhere
Sz: Size,
Like resolve, but the Pos must be non-none. Return its index.
Trait Implementations§
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)