pub struct UnorderedMap<K, V>(/* private fields */);
Expand description

Hash map which does not expose any insertion order-specific behavior (except Debug).

Implementations§

source§

impl<K, V> UnorderedMap<K, V>

source

pub const fn new() -> UnorderedMap<K, V>

Create a new empty map.

source

pub fn with_capacity(n: usize) -> UnorderedMap<K, V>

Create a new empty map with the specified capacity.

source

pub fn len(&self) -> usize

Get the number of elements in the map.

source

pub fn is_empty(&self) -> bool

Is the map empty?

source

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

Get a reference to the value associated with the given key.

source

pub fn get_hashed<Q>(&self, key: Hashed<&Q>) -> Option<&V>
where Q: Equivalent<K> + ?Sized,

Get a reference to the value associated with the given key.

source

pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
where Q: Hash + Equivalent<K> + ?Sized,

Get a mutable reference to the value associated with the given key.

source

pub fn contains_key<Q>(&self, k: &Q) -> bool
where Q: Hash + Equivalent<K> + ?Sized,

Does the map contain the specified key?

source

pub fn contains_key_hashed<Q>(&self, key: Hashed<&Q>) -> bool
where Q: Equivalent<K> + ?Sized,

Does the map contain the specified key?

source

pub fn insert(&mut self, k: K, v: V) -> Option<V>
where K: Hash + Eq,

Insert an entry into the map.

source

pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
where Q: Hash + Equivalent<K> + ?Sized,

Remove an entry from the map.

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&K, &mut V) -> bool,

Preserve only the elements specified by the predicate.

source

pub fn entry(&mut self, k: K) -> Entry<'_, K, V>
where K: Hash + Eq,

Get an entry in the map for in-place manipulation.

source

pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V>

Lower-level access to the entry API.

source

pub fn clear(&mut self)

Clear the map, removing all entries.

source

pub fn entries_unordered(&self) -> impl ExactSizeIterator<Item = (&K, &V)>

Entries in the map, in arbitrary order.

source

pub fn entries_unordered_mut( &mut self ) -> impl ExactSizeIterator<Item = (&K, &mut V)>

Entries in the map, in arbitrary order.

source

pub fn keys_unordered(&self) -> impl ExactSizeIterator<Item = &K>

Keys in the map, in arbitrary order.

source

pub fn values_unordered(&self) -> impl ExactSizeIterator<Item = &V>

Values in the map, in arbitrary order.

source

pub fn values_unordered_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>

Values in the map, in arbitrary order.

source

pub fn entries_sorted(&self) -> Vec<(&K, &V)>
where K: Ord,

Get the entries in the map, sorted by key.

source

pub fn into_hash_map(self) -> HashMap<K, V>
where K: Hash + Eq,

Convert into HashMap.

source

pub fn map_values<W>(self, f: impl FnMut(V) -> W) -> UnorderedMap<K, W>
where K: Hash + Eq,

Apply the function to value.

Trait Implementations§

source§

impl<K: Allocative, V: Allocative> Allocative for UnorderedMap<K, V>

source§

fn visit<'allocative_a, 'allocative_b: 'allocative_a>( &self, visitor: &'allocative_a mut Visitor<'allocative_b> )

source§

impl<K: Clone, V: Clone> Clone for UnorderedMap<K, V>

source§

fn clone(&self) -> UnorderedMap<K, V>

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<K: Debug, V: Debug> Debug for UnorderedMap<K, V>

source§

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

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

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

source§

fn default() -> UnorderedMap<K, V>

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

impl<K: Eq + Hash, V> FromIterator<(K, V)> for UnorderedMap<K, V>

source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> UnorderedMap<K, V>

Creates a value from an iterator. Read more
source§

impl<K: Hash, V: Hash> Hash for UnorderedMap<K, V>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<K, V, Q: Equivalent<K> + Hash> Index<&Q> for UnorderedMap<K, V>

§

type Output = V

The returned type after indexing.
source§

fn index(&self, k: &Q) -> &V

Performs the indexing (container[index]) operation. Read more
source§

impl<K: Eq + Hash, V: Eq> PartialEq for UnorderedMap<K, V>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K: Eq + Hash, V: Eq> Eq for UnorderedMap<K, V>

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for UnorderedMap<K, V>

§

impl<K, V> Send for UnorderedMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for UnorderedMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for UnorderedMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for UnorderedMap<K, V>
where K: UnwindSafe, V: 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

§

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

§

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

§

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.