Struct eytzinger_map::EytzingerMap [−][src]
pub struct EytzingerMap<S>(_);
A map based on a generic slice-compatible type with Eytzinger binary search.
Examples
use eytzinger_map::EytzingerMap; // `EytzingerMap` doesn't have insert. Build one from another map. let mut movie_reviews = std::collections::BTreeMap::new(); // review some movies. movie_reviews.insert("Office Space", "Deals with real issues in the workplace."); movie_reviews.insert("Pulp Fiction", "Masterpiece."); movie_reviews.insert("The Godfather", "Very enjoyable."); let movie_reviews: EytzingerMap<_> = movie_reviews.into_iter().collect(); // check for a specific one. if !movie_reviews.contains_key("Les Misérables") { println!("We've got {} reviews, but Les Misérables ain't one.", movie_reviews.len()); } // look up the values associated with some keys. let to_find = ["Up!", "Office Space"]; for movie in &to_find { match movie_reviews.get(movie) { Some(review) => println!("{}: {}", movie, review), None => println!("{} is unreviewed.", movie) } } // Look up the value for a key (will panic if the key is not found). println!("Movie review: {}", movie_reviews["Office Space"]); // iterate over everything. for (movie, review) in movie_reviews.iter() { println!("{}: \"{}\"", movie, review); }
Implementations
impl<S> EytzingerMap<S> where
S: AsSlice,
[src]
impl<S> EytzingerMap<S> where
S: AsSlice,
[src]pub fn new(s: S) -> Self where
S: AsMutSlice,
[src]
S: AsMutSlice,
pub fn from_sorted(s: S) -> Self where
S: AsSlice,
[src]
S: AsSlice,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&S::Value> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&S::Value> where
S::Key: Borrow<Q> + Ord,
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.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(1, "a")]); assert_eq!(map.get(&1), Some(&"a")); assert_eq!(map.get(&2), None);
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<&(S::Key, S::Value)> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<&(S::Key, S::Value)> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]Returns the key-value pair corresponding to the supplied key.
The supplied 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.
Examples
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(1, "a")]); assert_eq!(map.get_key_value(&1), Some(&(1, "a"))); assert_eq!(map.get_key_value(&2), None);
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]Returns true
if the map contains a value for the specified 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.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(1, "a")]); assert_eq!(map.contains_key(&1), true); assert_eq!(map.contains_key(&2), false);
pub fn iter(&self) -> impl Iterator<Item = &(S::Key, S::Value)>
[src]
pub fn iter(&self) -> impl Iterator<Item = &(S::Key, S::Value)>
[src]Gets an iterator over the entries of the map.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(3, "c"), (2, "b"), (1, "a")]); for (key, val) in map.iter() { println!("key: {} val: {}", key, val); }
pub fn keys(&self) -> impl Iterator<Item = &S::Key>
[src]
pub fn keys(&self) -> impl Iterator<Item = &S::Key>
[src]Gets an iterator over the keys of the map.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(2, "b"), (1, "a")]); for key in map.keys() { println!("{}", key); }
pub fn values(&self) -> impl Iterator<Item = &S::Value>
[src]
pub fn values(&self) -> impl Iterator<Item = &S::Value>
[src]Gets an iterator over the values of the map.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let map = EytzingerMap::new(vec![(1, "hello"), (2, "goodbye")]); for val in map.values() { println!("{}", val); }
impl<S> EytzingerMap<S> where
S: AsMutSlice,
[src]
impl<S> EytzingerMap<S> where
S: AsMutSlice,
[src]pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut S::Value> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
[src]
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut S::Value> where
S::Key: Borrow<Q> + Ord,
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.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let mut map = EytzingerMap::new(vec![(1, "a")]); if let Some(x) = map.get_mut(&1) { *x = "b"; } assert_eq!(map[&1], "b");
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut (S::Key, S::Value)>
[src]
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut (S::Key, S::Value)>
[src]Gets a mutable iterator over the entries of the map.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let mut map = EytzingerMap::new(vec![("a", 1), ("b", 2), ("c", 3)]); // Update all values for (_, val) in map.iter_mut() { *val *= 2; } for (key, val) in map.iter() { println!("key: {} val: {}", key, val); }
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut S::Value>
[src]
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut S::Value>
[src]Gets a mutable iterator over the values of the map.
Examples
Basic usage:
use eytzinger_map::EytzingerMap; let mut map = EytzingerMap::new(vec![("a", 1), ("b", 2), ("c", 3)]); for val in map.values_mut() { *val = *val + 10; } for val in map.values() { println!("{}", val); }
Trait Implementations
impl<S: Clone> Clone for EytzingerMap<S>
[src]
impl<S: Clone> Clone for EytzingerMap<S>
[src]fn clone(&self) -> EytzingerMap<S>
[src]
fn clone(&self) -> EytzingerMap<S>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<S: Debug> Debug for EytzingerMap<S>
[src]
impl<S: Debug> Debug for EytzingerMap<S>
[src]impl<S: Default> Default for EytzingerMap<S>
[src]
impl<S: Default> Default for EytzingerMap<S>
[src]fn default() -> EytzingerMap<S>
[src]
fn default() -> EytzingerMap<S>
[src]Returns the “default value” for a type. Read more
impl<K, V> FromIterator<(K, V)> for EytzingerMap<Vec<(K, V)>> where
K: Ord,
[src]
impl<K, V> FromIterator<(K, V)> for EytzingerMap<Vec<(K, V)>> where
K: Ord,
[src]impl<S: Hash> Hash for EytzingerMap<S>
[src]
impl<S: Hash> Hash for EytzingerMap<S>
[src]impl<Q: ?Sized, S> Index<&'_ Q> for EytzingerMap<S> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
S: AsSlice,
[src]
impl<Q: ?Sized, S> Index<&'_ Q> for EytzingerMap<S> where
S::Key: Borrow<Q> + Ord,
Q: Ord,
S: AsSlice,
[src]impl<S, K, V> IntoIterator for EytzingerMap<S> where
S: IntoIterator<Item = (K, V)>,
[src]
impl<S, K, V> IntoIterator for EytzingerMap<S> where
S: IntoIterator<Item = (K, V)>,
[src]impl<S: PartialEq> PartialEq<EytzingerMap<S>> for EytzingerMap<S>
[src]
impl<S: PartialEq> PartialEq<EytzingerMap<S>> for EytzingerMap<S>
[src]fn eq(&self, other: &EytzingerMap<S>) -> bool
[src]
fn eq(&self, other: &EytzingerMap<S>) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &EytzingerMap<S>) -> bool
[src]
fn ne(&self, other: &EytzingerMap<S>) -> bool
[src]This method tests for !=
.
impl<S: Copy> Copy for EytzingerMap<S>
[src]
impl<S: Eq> Eq for EytzingerMap<S>
[src]
impl<S> StructuralEq for EytzingerMap<S>
[src]
impl<S> StructuralPartialEq for EytzingerMap<S>
[src]
Auto Trait Implementations
impl<S> RefUnwindSafe for EytzingerMap<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<S> Send for EytzingerMap<S> where
S: Send,
S: Send,
impl<S> Sync for EytzingerMap<S> where
S: Sync,
S: Sync,
impl<S> Unpin for EytzingerMap<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for EytzingerMap<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more