pub struct Cursor<'a, K: BTreeKey, V, A: Allocator = Global> { /* private fields */ }
Expand description
A cursor over the elements of a BTree
.
Cursors point either to an element in the tree or to the end of the tree.
Iterators are more efficient than cursors. Prefer using them if you don’t need reverse iteration or if you don’t need to insert or remove elements in the tree.
This type is returned by BTree::cursor_at
and BTree::cursor
.
Implementations§
Source§impl<'a, K: BTreeKey, V, A: Allocator> Cursor<'a, K, V, A>
impl<'a, K: BTreeKey, V, A: Allocator> Cursor<'a, K, V, A>
Sourcepub fn key(&self) -> Option<K>
pub fn key(&self) -> Option<K>
Returns the key of the element that the cursor is currently pointing to,
or None
if the cursor is pointing to the end of the tree.
Sourcepub fn value(&self) -> Option<&'a V>
pub fn value(&self) -> Option<&'a V>
Returns a reference to the value that the cursor is currently
pointing to, or None
if the cursor is pointing to the end of the tree.
Sourcepub fn entry(&self) -> Option<(K, &'a V)>
pub fn entry(&self) -> Option<(K, &'a V)>
Returns the key and a reference to the value that the cursor is
currently pointing to, or None
if the cursor is pointing to the end of
the tree.
Sourcepub fn next(&mut self)
pub fn next(&mut self)
Advances the cursor to the next element in the tree.
§Panics
Panics if the cursor is pointing to the end of the tree.