Struct HashMap

Source
pub struct HashMap<K, V, S = RandomState> { /* private fields */ }

Implementations§

Source§

impl<K, V> HashMap<K, V>

Source

pub fn new() -> Self

Creates an empty HashMap.

The hash map is initially created with a capacity of 0, so it will not allocate until it is first inserted into.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty HashMap with the specified capacity.

The hash map will be able to hold at least capacity elements without reallocating. If capacity is 0, the hash map will not allocate.

Source§

impl<K: Hash, V, S: BuildHasher> HashMap<K, V, S>

Source

pub fn read<'a>(&'a self, key: &'a K) -> Readable<'a, K, V, S>

Source

pub fn write(&self, key: K) -> Writeable<'_, K, V, S>

Source

pub fn shard(&self, key: &K) -> &RwLock<Map<K, V, S>>

Source

pub fn shard_idx(&self, key: &K) -> usize

Source§

impl<K, V, S: Clone> HashMap<K, V, S>

Source

pub fn shards(&self) -> &[RwLock<Map<K, V, S>>]

Get a reference to the map’s shards.

Source

pub fn with_hasher(hasher: S) -> Self

Creates an empty HashMap which will use the given hash builder to hash keys.

The created map has the default initial capacity.

Warning: hash_builder is normally randomly generated, and is designed to allow HashMaps to be resistant to attacks that cause many collisions and very poor performance. Setting it manually using this function can expose a DoS attack vector.

The hash_builder passed should implement the BuildHasher trait for the HashMap to be useful.

Source

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

Creates an empty HashMap with the specified capacity, using hash_builder to hash the keys.

The hash map will be able to hold at least capacity elements without reallocating. If capacity is 0, the hash map will not allocate.

Warning: hash_builder is normally randomly generated, and is designed to allow HashMaps to be resistant to attacks that cause many collisions and very poor performance. Setting it manually using this function can expose a DoS attack vector.

The hash_builder passed should implement the BuildHasher trait for the HashMap to be useful.

Trait Implementations§

Source§

impl<K, V> Default for HashMap<K, V>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, V, S> Freeze for HashMap<K, V, S>
where S: Freeze,

§

impl<K, V, S> RefUnwindSafe for HashMap<K, V, S>
where S: RefUnwindSafe,

§

impl<K, V, S> Send for HashMap<K, V, S>
where S: Send, K: Send, V: Send,

§

impl<K, V, S> Sync for HashMap<K, V, S>
where S: Sync + Send, K: Send + Sync, V: Send + Sync,

§

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

§

impl<K, V, S> UnwindSafe for HashMap<K, V, S>
where S: 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, 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.