pub struct TdfMap<K, V> { /* private fields */ }
Expand description
Structure for maps used in the protocol. These maps have a special order that is usually required and they retain the order of insertion because it uses two vecs as the underlying structure
Implementations§
source§impl<K, V> TdfMap<K, V>
impl<K, V> TdfMap<K, V>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Function for creating a new TdfMap where the underlying lists have an initial capacity
capacity
The capacity
sourcepub fn iter(&self) -> MapEntryIter<'_, K, V> ⓘ
pub fn iter(&self) -> MapEntryIter<'_, K, V> ⓘ
Creates a new iterator over the underlying items in the map
sourcepub fn index(&self, index: usize) -> Option<(&K, &V)>
pub fn index(&self, index: usize) -> Option<(&K, &V)>
Returns the key and value stored at the provided index will return None if there is nothing at the provided index
sourcepub fn insert<A: Into<K>, B: Into<V>>(&mut self, key: A, value: B)
pub fn insert<A: Into<K>, B: Into<V>>(&mut self, key: A, value: B)
Inserts a new key value pair into the underlying structure.
This function does NOT maintain order of the entires, use
insert_ordered
instead for maintaining the order
key
The entry key
value
The entry value
source§impl<K, V> TdfMap<K, V>where
K: PartialOrd + Ord,
impl<K, V> TdfMap<K, V>where K: PartialOrd + Ord,
source§impl<K, V> TdfMap<K, V>where
K: PartialEq + Eq,
impl<K, V> TdfMap<K, V>where K: PartialEq + Eq,
sourcepub fn extend(&mut self, other: TdfMap<K, V>)
pub fn extend(&mut self, other: TdfMap<K, V>)
Extends this map with the contents of another map. Any keys that already exist in the map will be replaced with the keys from the other map and any keys not present will be inserted
other
The map to extend with
sourcepub fn remove(&mut self, key: &K) -> Option<(K, V)>
pub fn remove(&mut self, key: &K) -> Option<(K, V)>
Removes a value by its key and returns the entry that was present at that position.
key
The key to remove
sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&V>where K: Borrow<Q>, Q: Eq + ?Sized,
Returns the value stored at the provided key if its present or None.
key
The key to retrieve the value for
Trait Implementations§
source§impl<K, V> Decodable for TdfMap<K, V>where
K: Decodable + ValueType,
V: Decodable + ValueType,
impl<K, V> Decodable for TdfMap<K, V>where K: Decodable + ValueType, V: Decodable + ValueType,
source§impl<K, V> Encodable for TdfMap<K, V>where
K: Encodable + ValueType,
V: Encodable + ValueType,
impl<K, V> Encodable for TdfMap<K, V>where K: Encodable + ValueType, V: Encodable + ValueType,
source§impl<K, V> From<HashMap<K, V, RandomState>> for TdfMap<K, V>
impl<K, V> From<HashMap<K, V, RandomState>> for TdfMap<K, V>
Implementation for converting a HashMap to a TdfMap by taking all its keys and values and building lists for the TdfMap
source§impl<'a, K, V> IntoIterator for &'a TdfMap<K, V>
impl<'a, K, V> IntoIterator for &'a TdfMap<K, V>
Into iterator implementation for borrowed map
source§impl<K, V> IntoIterator for TdfMap<K, V>
impl<K, V> IntoIterator for TdfMap<K, V>
Into iterator implementation for owned map