pub struct RawSharedIter<'t, K, V, const IC: usize, const LC: usize> { /* private fields */ }Expand description
Raw shared iterator over the entries of the tree.
Implementations§
Sourcepub fn seek<Q>(&mut self, key: &Q)
pub fn seek<Q>(&mut self, key: &Q)
Sets the iterator cursor immediately before the position for this key.
Seeks to the position even though no value associated with the key exists on the tree.
A subsequent call of RawSharedIter::next should return the entry associated with this key or the one
immediately following it.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek(&2);
assert_eq!(iter.next(), Some((&2, &"b")));
iter.seek(&1);
assert_eq!(iter.next(), Some((&2, &"b")));
iter.seek(&3);
assert_eq!(iter.next(), None);Sourcepub fn seek_for_prev<Q>(&mut self, key: &Q)
pub fn seek_for_prev<Q>(&mut self, key: &Q)
Sets the iterator cursor immediately after the position for this key.
Seeks to the position even though no value associated with the key exists on the tree.
A subsequent call of RawSharedIter::prev should return the entry associated with this key or the one
immediately preceding it.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek_for_prev(&2);
assert_eq!(iter.prev(), Some((&2, &"b")));
iter.seek_for_prev(&3);
assert_eq!(iter.prev(), Some((&2, &"b")));
iter.seek_for_prev(&1);
assert_eq!(iter.prev(), None);Sourcepub fn seek_exact<Q>(&mut self, key: &Q) -> bool
pub fn seek_exact<Q>(&mut self, key: &Q) -> bool
Sets the iterator cursor immediately before the position for this key, returning true if
the next entry matches the provided key.
A subsequent call of RawSharedIter::next should return the entry associated with this
key if the method returned true.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
tree.insert(2, "b");
let mut iter = tree.raw_iter();
assert_eq!(iter.seek_exact(&2), true);
assert_eq!(iter.next(), Some((&2, &"b")));
assert_eq!(iter.seek_exact(&1), false);
assert_eq!(iter.next(), Some((&2, &"b")));
assert_eq!(iter.seek_exact(&3), false);
assert_eq!(iter.next(), None);Sourcepub fn seek_to_first(&mut self)
pub fn seek_to_first(&mut self)
Sets the iterator cursor immediately before the position for the first key in the tree.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
let mut iter = tree.raw_iter();
iter.seek_to_first();
assert_eq!(iter.next(), None);
// Calling insert on the tree while holding an iterator
// in the same thread may deadlock, so we drop here
drop(iter);
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek_to_first();
assert_eq!(iter.next(), Some((&2, &"b")));Sourcepub fn seek_to_last(&mut self)
pub fn seek_to_last(&mut self)
Sets the iterator cursor immediately after the position for the last key in the tree.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
let mut iter = tree.raw_iter();
iter.seek_to_last();
assert_eq!(iter.prev(), None);
// Calling insert on the tree while holding an iterator
// in the same thread may deadlock, so we drop here
drop(iter);
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek_to_last();
assert_eq!(iter.prev(), Some((&2, &"b")));Sourcepub fn next(&mut self) -> Option<(&K, &V)>
pub fn next(&mut self) -> Option<(&K, &V)>
Returns the next entry from the current cursor position.
If the cursor was not seeked to any position this will always return None. This behavior
may change in the future.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek_to_first();
assert_eq!(iter.next(), Some((&2, &"b")));
assert_eq!(iter.next(), None);Sourcepub fn prev(&mut self) -> Option<(&K, &V)>
pub fn prev(&mut self) -> Option<(&K, &V)>
Returns the previous entry from the current cursor position.
If the cursor was not seeked to any position this will always return None. This behavior
may change in the future.
§Examples
Basic usage:
use bplustree::BPlusTree;
let tree = BPlusTree::new();
tree.insert(2, "b");
let mut iter = tree.raw_iter();
iter.seek_to_last();
assert_eq!(iter.prev(), Some((&2, &"b")));
assert_eq!(iter.prev(), None);