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]

Move cursor to next pos.

Move cursor to next pos.

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);

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);

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);

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);

Auto Trait Implementations

impl<'a, K, V> !Send for Cursors<'a, K, V>

impl<'a, K, V> !Sync for Cursors<'a, K, V>