[][src]Struct avl::AvlTreeMap

pub struct AvlTreeMap<K, V> { /* fields omitted */ }

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.

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 get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
    K: Borrow<Q>,
    Q: Ord
[src]

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
    K: Borrow<Q>,
    Q: Ord
[src]

Returns a mutable reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)> where
    K: Borrow<Q>,
    Q: Ord
[src]

Returns references to the key-value pair corresponding to the key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Ord
[src]

Returns true if the key is in the map, else false.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where
    K: Borrow<Q>,
    Q: Ord
[src]

Removes a key from the map. Returns the value at the key if the key was previously in the map.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)> where
    K: Borrow<Q>,
    Q: Ord
[src]

Removes a key from the map. Returns the stored key and value if the key was previously in the map.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

pub fn range<Q: ?Sized, R>(&self, range: R) -> Range<'_, K, V>

Notable traits for Range<'a, K, V>

impl<'a, K, V> Iterator for Range<'a, K, V> type Item = (&'a K, &'a V);
where
    K: Borrow<Q>,
    R: RangeBounds<Q>,
    Q: Ord
[src]

Gets an iterator over a range of elements in the map, in order by key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

Panics

Panics if range start > end. Panics if range start == end and both bounds are Excluded.

pub fn range_mut<Q: ?Sized, R>(&mut self, range: R) -> RangeMut<'_, K, V>

Notable traits for RangeMut<'a, K, V>

impl<'a, K, V> Iterator for RangeMut<'a, K, V> type Item = (&'a K, &'a mut V);
where
    K: Borrow<Q>,
    R: RangeBounds<Q>,
    Q: Ord
[src]

Gets a mutable iterator over a range of elements in the map, in order by key.

The key may be any borrowed form of the map's key type, but the ordering on the borrowed form must match the ordering on the key type.

Panics

Panics if range start > end. Panics if range start == end and both bounds are Excluded.

pub fn iter(&self) -> Iter<'_, K, V>

Notable traits for Iter<'a, K, V>

impl<'a, K, V> Iterator for Iter<'a, K, V> type Item = (&'a K, &'a V);
[src]

Gets an iterator over the entries of the map, sorted by key.

pub fn keys(&self) -> Keys<'_, K, V>

Notable traits for Keys<'a, K, V>

impl<'a, K, V> Iterator for Keys<'a, K, V> type Item = &'a K;
[src]

Gets an iterator over the keys of the map, in sorted order.

pub fn values(&self) -> Values<'_, K, V>

Notable traits for Values<'a, K, V>

impl<'a, K, V> Iterator for Values<'a, K, V> type Item = &'a V;
[src]

Gets an iterator over the values of the map, in order by key.

pub fn values_mut(&self) -> ValuesMut<'_, K, V>

Notable traits for ValuesMut<'a, K, V>

impl<'a, K, V> Iterator for ValuesMut<'a, K, V> type Item = &'a mut 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>

Notable traits for IterMut<'a, K, V>

impl<'a, K, V> Iterator for IterMut<'a, K, V> type Item = (&'a K, &'a mut V);
[src]

Gets a mutable iterator over the entries of the map, sorted by key.

impl<K: Ord, V> AvlTreeMap<K, V>[src]

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 append(&mut self, other: &mut Self)[src]

Moves all elements from other into self, leaving other empty.

pub fn split_off<Q: ?Sized>(&mut self, key: &Q) -> Self where
    K: Borrow<Q>,
    Q: Ord
[src]

Splits the collection into two at the given key. Returns everything after the given key, including the key.

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>[src]

Gets the map entry of given key for in-place manipulation.

Trait Implementations

impl<K: Clone, V: Clone> Clone for AvlTreeMap<K, V>[src]

impl<K, V> Debug for AvlTreeMap<K, V> where
    K: Debug,
    V: Debug
[src]

impl<K: Ord, V> Default for AvlTreeMap<K, V>[src]

fn default() -> Self[src]

Creates an empty map.

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]

impl<K: Ord, V> Extend<(K, V)> for AvlTreeMap<K, V>[src]

impl<K: Ord, V> FromIterator<(K, V)> for AvlTreeMap<K, V>[src]

impl<K: Hash, V: Hash> Hash for AvlTreeMap<K, V>[src]

impl<Q: ?Sized, K, V, '_> Index<&'_ Q> for AvlTreeMap<K, V> where
    K: Ord + Borrow<Q>,
    Q: Ord
[src]

type Output = V

The returned type after indexing.

fn index(&self, key: &Q) -> &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?

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?

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?

impl<K: Ord, V: Ord> Ord for AvlTreeMap<K, V>[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]

impl<K, V> Send for AvlTreeMap<K, V>[src]

impl<K, V> Sync for AvlTreeMap<K, V>[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for AvlTreeMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Unpin for AvlTreeMap<K, V>

impl<K, V> UnwindSafe for AvlTreeMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.