Struct hash_ord::ord_map::Cursors [−][src]
pub struct Cursors<'a, K, V> where
K: Ord + 'a,
V: 'a, { /* fields omitted */ }
An cursor of a OrdMap
.
This struct is constructed from the find_cursors
method on OrdMap
.
Methods
impl<'a, K, V> Cursors<'a, K, V> where
K: Ord,
[src]
impl<'a, K, V> Cursors<'a, K, V> where
K: Ord,
pub fn next(&mut self)
[src]
pub fn next(&mut self)
Move cursor to next pos.
pub fn prev(&mut self)
[src]
pub fn prev(&mut self)
Move cursor to next pos.
pub fn get(&self) -> Option<(&K, &V)>
[src]
pub fn get(&self) -> Option<(&K, &V)>
Returns the (&Key, &Value) pair of current pos.
Examples
use hash_ord::ord_map::OrdMap; use hash_ord::ord_map::Cursors; let mut map = OrdMap::new(); map.insert(1, 1); map.insert(2, 2); map.insert(3, 3); let mut cursors = map.find_cursors(&2); assert_eq!(*cursors.get().unwrap().0, 2);
pub fn get_mut(&mut self) -> Option<(&K, &mut V)>
[src]
pub fn get_mut(&mut self) -> Option<(&K, &mut V)>
Returns the (&Key, &mut Value) pair of current pos.
Examples
use hash_ord::ord_map::OrdMap; use hash_ord::ord_map::Cursors; let mut map = OrdMap::new(); map.insert(1, 1); map.insert(2, 2); map.insert(3, 3); let mut cursors = map.find_cursors(&2); *cursors.get_mut().unwrap().1 = -2; assert_eq!(*cursors.get().unwrap().1, -2);
pub fn erase_then_next(&mut self) -> Option<(K, V)>
[src]
pub fn erase_then_next(&mut self) -> Option<(K, V)>
Erase current pos, and move to next.
Examples
use hash_ord::ord_map::OrdMap; use hash_ord::ord_map::Cursors; let mut map = OrdMap::new(); map.insert(1, 1); map.insert(2, 2); map.insert(3, 3); let mut cursors = map.find_cursors(&2); let x = cursors.erase_then_next(); assert_eq!(x.unwrap().0, 2); assert_eq!(*cursors.get().unwrap().0, 3);
pub fn erase_then_prev(&mut self) -> Option<(K, V)>
[src]
pub fn erase_then_prev(&mut self) -> Option<(K, V)>
Erase current pos, and move to prev.
Examples
use hash_ord::ord_map::OrdMap; use hash_ord::ord_map::Cursors; let mut map = OrdMap::new(); map.insert(1, 1); map.insert(2, 2); map.insert(3, 3); let mut cursors = map.find_cursors(&2); let x = cursors.erase_then_prev(); assert_eq!(x.unwrap().0, 2); assert_eq!(*cursors.get().unwrap().0, 1);