Struct netsblox_vm::vecmap::VecMap
source · pub struct VecMap<K: Ord + 'static, V, const SORTED: bool> { /* private fields */ }Expand description
A map type implemented as a list of key/value pairs.
If the const generic SORTED is set to true, keys will be sorted in ascending order, lookups are O(log(n)), and insertions are O(n).
If SORTED is set to false, keys will be sorted in insertion order, lookups are O(n), and insertions are O(1).
Implementations§
source§impl<K: Ord + 'static, V, const SORTED: bool> VecMap<K, V, SORTED>
impl<K: Ord + 'static, V, const SORTED: bool> VecMap<K, V, SORTED>
sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Creates a new, empty map with the specified capacity.
sourcepub fn get<Q: ?Sized + Ord>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
pub fn get<Q: ?Sized + Ord>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Gets an immutable reference to a stored value, if it exists.
sourcepub fn get_mut<Q: ?Sized + Ord>(&mut self, key: &Q) -> Option<&mut V>where
K: Borrow<Q>,
pub fn get_mut<Q: ?Sized + Ord>(&mut self, key: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Gets a mutable reference to a stored value, if it exists.
Trait Implementations§
source§impl<K: Ord + 'static, V, const SORTED: bool> Collect for VecMap<K, V, SORTED>where
V: Collect,
impl<K: Ord + 'static, V, const SORTED: bool> Collect for VecMap<K, V, SORTED>where
V: Collect,
source§fn needs_trace() -> bool
fn needs_trace() -> bool
As an optimization, if this type can never hold a
Gc pointer and trace is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace must be called.source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Must call
Collect::trace on all held Gc pointers. If this type holds inner types that
implement Collect, a valid implementation would simply call Collect::trace on all the
held values to ensure this.source§impl<'de, K, V, const SORTED: bool> Deserialize<'de> for VecMap<K, V, SORTED>
impl<'de, K, V, const SORTED: bool> Deserialize<'de> for VecMap<K, V, SORTED>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<K, V, const SORTED: bool> RefUnwindSafe for VecMap<K, V, SORTED>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const SORTED: bool> Send for VecMap<K, V, SORTED>
impl<K, V, const SORTED: bool> Sync for VecMap<K, V, SORTED>
impl<K, V, const SORTED: bool> Unpin for VecMap<K, V, SORTED>
impl<K, V, const SORTED: bool> UnwindSafe for VecMap<K, V, SORTED>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
Mutably borrows from an owned value. Read more