Skip to main content

HopscotchMap

Struct HopscotchMap 

Source
pub struct HopscotchMap<K: 'static, V: 'static, S = FixedState> { /* private fields */ }
Expand description

A concurrent, lock-free hash map based on Hopscotch Hashing.

Implementations§

Source§

impl<K, V> HopscotchMap<K, V, FixedState>
where K: Hash + Eq + Clone + 'static, V: Clone + 'static,

Source

pub fn new() -> Self

Creates a new HopscotchMap with default capacity and hasher.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new HopscotchMap with the specified capacity and default hasher.

Source§

impl<K, V, S> HopscotchMap<K, V, S>
where K: Hash + Eq + Clone + 'static, V: Clone + 'static, S: BuildHasher,

Source

pub fn with_hasher(hasher: S) -> Self

Creates a new HopscotchMap with the specified hasher and default capacity.

Source

pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> Self

Creates a new HopscotchMap with the specified capacity and hasher.

Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Source

pub fn capacity(&self) -> usize

Returns the current capacity of the map.

Source

pub fn get<Q>(&self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns the value corresponding to the key.

Source

pub fn insert(&self, key: K, value: V) -> Option<V>

Inserts a key-value pair into the map.

Source

pub fn get_or_insert(&self, key: K, value: V) -> V

Returns the value corresponding to the key, or inserts the given value if the key is not present.

Source

pub fn insert_if_absent(&self, key: K, value: V) -> Option<V>

Insert a key-value pair only if the key does not exist. Returns None if inserted, Some(existing_value) if the key already exists.

Source

pub fn remove<Q>(&self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Removes a key from the map, returning the value at the key if the key was previously in the map.

Source

pub fn clear(&self)

Clears the map, removing all key-value pairs.

Source

pub fn iter(&self) -> HopscotchIter<'_, K, V, S>

Returns an iterator over the map entries.

Source

pub fn keys(&self) -> HopscotchKeys<'_, K, V, S>

Returns an iterator over the map keys.

Source

pub fn hasher(&self) -> &S

Get the underlying hasher.

Trait Implementations§

Source§

impl<K, V> Default for HopscotchMap<K, V, FixedState>
where K: Hash + Eq + Clone + 'static, V: Clone + 'static,

Available on crate feature std only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, V, S> Drop for HopscotchMap<K, V, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, K, V, S> IntoIterator for &'a HopscotchMap<K, V, S>
where K: Hash + Eq + Clone + 'static, V: Clone + 'static, S: BuildHasher,

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = HopscotchIter<'a, K, V, S>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Send, V: Send, S: Send> Send for HopscotchMap<K, V, S>

Source§

impl<K: Sync, V: Sync, S: Sync> Sync for HopscotchMap<K, V, S>

Auto Trait Implementations§

§

impl<K, V, S = FixedState> !Freeze for HopscotchMap<K, V, S>

§

impl<K, V, S> RefUnwindSafe for HopscotchMap<K, V, S>

§

impl<K, V, S> Unpin for HopscotchMap<K, V, S>
where S: Unpin,

§

impl<K, V, S> UnwindSafe for HopscotchMap<K, V, S>

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