[−][src]Trait consistent_hash_ring::collections::Map
Required methods
fn map_insert(&mut self, key: K, val: V) -> Option<V>
Insert a value at key.
Returns None
if the key doesn't exist, and Some(old_value)
when
it does.
fn map_remove(&mut self, key: &K) -> Option<(K, V)>
Remove the value at key.
Returns None
if the key doesn't exist.
fn map_lookup(&self, key: &K) -> Option<&V>
Lookup the value at key.
Returns None
if the key doesn't exist.
fn find_gte(&self, key: &K) -> Option<&V>
Find the smallest key that is greater than or equal to key, wrapping to zero if there isn't one.
Returns None
if the map is empty.
Implementations on Foreign Types
impl<K: Ord, V> Map<K, V> for Vec<(K, V)>
[src]
fn map_insert(&mut self, key: K, val: V) -> Option<V>
[src]
O(n + log n)
use consistent_hash_ring::collections::Map; let mut map = (0..2).map(|x|(x,x)).collect::<Vec<_>>(); assert_eq!(None, map.map_insert(2, 42)); assert_eq!(vec![(0, 0), (1, 1), (2, 42)], map); assert_eq!(Some(42), map.map_insert(2, 24)); assert_eq!(vec![(0, 0), (1, 1), (2, 24)], map);
fn map_remove(&mut self, key: &K) -> Option<(K, V)>
[src]
O(n + log n)
use consistent_hash_ring::collections::Map; let mut map = (0..2).map(|x|(x,x)).collect::<Vec<_>>(); assert_eq!(None, map.map_remove(&4)); assert_eq!(Some((1, 1)), map.map_remove(&1)); assert_eq!(vec![(0, 0)], map);
fn map_lookup(&self, key: &K) -> Option<&V>
[src]
O(log n)
use consistent_hash_ring::collections::Map; let mut map = (0..2).map(|x|(x,x)).collect::<Vec<_>>(); assert_eq!(Some(&1), map.map_lookup(&1)); assert_eq!(None, map.map_lookup(&3));
fn find_gte(&self, key: &K) -> Option<&V>
[src]
O(log n)
use consistent_hash_ring::collections::Map; let mut map = Vec::default(); assert_eq!(None, map.find_gte(&0)); assert_eq!(None, map.map_insert(1, 2)); assert_eq!(None, map.map_insert(2, 3)); assert_eq!(None, map.map_insert(3, 4)); assert_eq!(vec![(1, 2), (2, 3), (3, 4)], map); assert_eq!(Some(&2), map.find_gte(&0)); assert_eq!(Some(&2), map.find_gte(&1)); assert_eq!(Some(&3), map.find_gte(&2)); assert_eq!(Some(&4), map.find_gte(&3)); assert_eq!(Some(&2), map.find_gte(&4));