Struct starlark_map::unordered_map::UnorderedMap
source · 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>
impl<K, V> UnorderedMap<K, V>
sourcepub const fn new() -> UnorderedMap<K, V>
pub const fn new() -> UnorderedMap<K, V>
Create a new empty map.
sourcepub fn with_capacity(n: usize) -> UnorderedMap<K, V>
pub fn with_capacity(n: usize) -> UnorderedMap<K, V>
Create a new empty map with the specified capacity.
sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Get a reference to the value associated with the given key.
sourcepub fn get_hashed<Q>(&self, key: Hashed<&Q>) -> Option<&V>where
Q: Equivalent<K> + ?Sized,
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.
sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Get a mutable reference to the value associated with the given key.
sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Does the map contain the specified key?
sourcepub fn contains_key_hashed<Q>(&self, key: Hashed<&Q>) -> boolwhere
Q: Equivalent<K> + ?Sized,
pub fn contains_key_hashed<Q>(&self, key: Hashed<&Q>) -> boolwhere
Q: Equivalent<K> + ?Sized,
Does the map contain the specified key?
sourcepub fn entry(&mut self, k: K) -> Entry<'_, K, V>
pub fn entry(&mut self, k: K) -> Entry<'_, K, V>
Get an entry in the map for in-place manipulation.
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V>
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V>
Lower-level access to the entry API.
sourcepub fn entries_unordered(&self) -> impl ExactSizeIterator<Item = (&K, &V)>
pub fn entries_unordered(&self) -> impl ExactSizeIterator<Item = (&K, &V)>
Entries in the map, in arbitrary order.
sourcepub fn entries_unordered_mut(
&mut self
) -> impl ExactSizeIterator<Item = (&K, &mut V)>
pub fn entries_unordered_mut( &mut self ) -> impl ExactSizeIterator<Item = (&K, &mut V)>
Entries in the map, in arbitrary order.
sourcepub fn keys_unordered(&self) -> impl ExactSizeIterator<Item = &K>
pub fn keys_unordered(&self) -> impl ExactSizeIterator<Item = &K>
Keys in the map, in arbitrary order.
sourcepub fn values_unordered(&self) -> impl ExactSizeIterator<Item = &V>
pub fn values_unordered(&self) -> impl ExactSizeIterator<Item = &V>
Values in the map, in arbitrary order.
sourcepub fn values_unordered_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
pub fn values_unordered_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
Values in the map, in arbitrary order.
sourcepub fn entries_sorted(&self) -> Vec<(&K, &V)>where
K: Ord,
pub fn entries_sorted(&self) -> Vec<(&K, &V)>where
K: Ord,
Get the entries in the map, sorted by key.
sourcepub fn into_hash_map(self) -> HashMap<K, V>
pub fn into_hash_map(self) -> HashMap<K, V>
Convert into HashMap
.
sourcepub fn map_values<W>(self, f: impl FnMut(V) -> W) -> UnorderedMap<K, W>
pub fn map_values<W>(self, f: impl FnMut(V) -> W) -> UnorderedMap<K, W>
Apply the function to value.
Trait Implementations§
source§impl<K: Allocative, V: Allocative> Allocative for UnorderedMap<K, V>
impl<K: Allocative, V: Allocative> Allocative for UnorderedMap<K, V>
source§impl<K: Clone, V: Clone> Clone for UnorderedMap<K, V>
impl<K: Clone, V: Clone> Clone for UnorderedMap<K, V>
source§fn clone(&self) -> UnorderedMap<K, V>
fn clone(&self) -> UnorderedMap<K, V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<K, V> Default for UnorderedMap<K, V>
impl<K, V> Default for UnorderedMap<K, V>
source§fn default() -> UnorderedMap<K, V>
fn default() -> UnorderedMap<K, V>
source§impl<K: Eq + Hash, V> FromIterator<(K, V)> for UnorderedMap<K, V>
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>
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> UnorderedMap<K, V>
source§impl<K, V, Q: Equivalent<K> + Hash> Index<&Q> for UnorderedMap<K, V>
impl<K, V, Q: Equivalent<K> + Hash> Index<&Q> for UnorderedMap<K, V>
source§impl<K: Eq + Hash, V: Eq> PartialEq for UnorderedMap<K, V>
impl<K: Eq + Hash, V: Eq> PartialEq for UnorderedMap<K, V>
impl<K: Eq + Hash, V: Eq> Eq for UnorderedMap<K, V>
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for UnorderedMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for UnorderedMap<K, V>
impl<K, V> Sync for UnorderedMap<K, V>
impl<K, V> Unpin for UnorderedMap<K, V>
impl<K, V> UnwindSafe for UnorderedMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.