[−][src]Struct avl::AvlTreeMap
An ordered map implemented with an AVL tree.
use avl::AvlTreeMap; let mut map = AvlTreeMap::new(); map.insert(0, "zero"); map.insert(1, "one"); map.insert(2, "two"); assert_eq!(map.get(&1), Some(&"one")); map.remove(&1); assert!(map.get(&1).is_none());
Implementations
impl<K: Ord, V> AvlTreeMap<K, V>
[src]
pub fn new() -> Self
[src]
Creates an empty map. No memory is allocated until the first item is inserted.
pub fn get(&self, key: &K) -> Option<&V>
[src]
Returns a reference to the value corresponding to the key.
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
[src]
Returns a mutable reference to the value corresponding to the key.
pub fn get_key_value(&self, key: &K) -> Option<(&K, &V)>
[src]
Returns references to the key-value pair corresponding to the key.
pub fn contains_key(&self, key: &K) -> bool
[src]
Returns true if the key is in the map, else false.
pub fn insert(&mut self, key: K, value: V) -> Option<V>
[src]
Inserts a key-value pair into the map. Returns None if the key is not in the map. Updates the value if the key is already in the map and returns the old value.
pub fn remove(&mut self, key: &K) -> Option<V>
[src]
Removes a key from the map. Returns the value at the key if the key was previously in the map.
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>
[src]
Removes a key from the map. Returns the stored key and value if the key was previously in the map.
pub fn append(&mut self, other: &mut Self)
[src]
Moves all elements from other into self, leaving other empty.
pub fn range<R: RangeBounds<K>>(&self, range: R) -> Range<'_, K, V>ⓘ
[src]
Gets an iterator over a range of elements in the map, in order by key.
pub fn range_mut<R: RangeBounds<K>>(&mut self, range: R) -> RangeMut<'_, K, V>ⓘ
[src]
Gets a mutable iterator over a range of elements in the map, in order by key.
impl<K, V> AvlTreeMap<K, V>
[src]
pub fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
pub fn len(&self) -> usize
[src]
Returns the number of elements in the map.
pub fn clear(&mut self)
[src]
Clears the map, deallocating all memory.
pub fn iter(&self) -> Iter<'_, K, V>ⓘ
[src]
Gets an iterator over the entries of the map, sorted by key.
pub fn keys(&self) -> Keys<'_, K, V>ⓘ
[src]
Gets an iterator over the keys of the map, in sorted order.
pub fn values(&self) -> Values<'_, K, V>ⓘ
[src]
Gets an iterator over the values of the map, in order by key.
pub fn values_mut(&self) -> ValuesMut<'_, K, V>ⓘ
[src]
Gets a mutable iterator over the values of the map, in order by key.
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘ
[src]
Gets a mutable iterator over the entries of the map, sorted by key.
Trait Implementations
impl<K: Clone, V: Clone> Clone for AvlTreeMap<K, V>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K, V> Debug for AvlTreeMap<K, V> where
K: Debug,
V: Debug,
[src]
K: Debug,
V: Debug,
impl<K: Ord, V> Default for AvlTreeMap<K, V>
[src]
impl<K, V> Drop for AvlTreeMap<K, V>
[src]
impl<K: Eq, V: Eq> Eq for AvlTreeMap<K, V>
[src]
impl<'a, K, V> Extend<(&'a K, &'a V)> for AvlTreeMap<K, V> where
K: Ord + Copy,
V: Copy,
[src]
K: Ord + Copy,
V: Copy,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (&'a K, &'a V)>,
[src]
I: IntoIterator<Item = (&'a K, &'a V)>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<K, V> Extend<(K, V)> for AvlTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (K, V)>,
[src]
I: IntoIterator<Item = (K, V)>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<K: Ord, V> FromIterator<(K, V)> for AvlTreeMap<K, V>
[src]
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
[src]
impl<K: Ord, V, '_> Index<&'_ K> for AvlTreeMap<K, V>
[src]
type Output = V
The returned type after indexing.
fn index(&self, key: &K) -> &V
[src]
Returns a reference to the value for the given key.
Panics
Panics if the key is not present in the map.
impl<'a, K, V> IntoIterator for &'a AvlTreeMap<K, V>
[src]
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, K, V> IntoIterator for &'a mut AvlTreeMap<K, V>
[src]
type Item = (&'a K, &'a mut V)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<K, V> IntoIterator for AvlTreeMap<K, V>
[src]
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = IntoIter<K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<K: Ord, V: Ord> Ord for AvlTreeMap<K, V>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<K: PartialEq, V: PartialEq> PartialEq<AvlTreeMap<K, V>> for AvlTreeMap<K, V>
[src]
impl<K: PartialOrd, V: PartialOrd> PartialOrd<AvlTreeMap<K, V>> for AvlTreeMap<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for AvlTreeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Send for AvlTreeMap<K, V>
impl<K, V> !Sync for AvlTreeMap<K, V>
impl<K, V> Unpin for AvlTreeMap<K, V>
impl<K, V> UnwindSafe for AvlTreeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,