pub struct Cursor<'a, K, V> { /* private fields */ }Expand description
A bidirectional immutable cursor over the tree nodes, sorted by key. This is a simpler
variant of CursorMut that is basically providing read only access.
§Examples
In the following example, we obtain a cursor to the first element in the tree. The cursor allows us to iterate bidirectionally over key/value pairs in the tree.
use kernel::{alloc::flags, rbtree::RBTree};
// Create a new tree.
let mut tree = RBTree::new();
// Insert three elements.
tree.try_create_and_insert(10, 100, flags::GFP_KERNEL)?;
tree.try_create_and_insert(20, 200, flags::GFP_KERNEL)?;
tree.try_create_and_insert(30, 300, flags::GFP_KERNEL)?;
// Get a cursor to the first element.
let cursor = tree.cursor_front().unwrap();
let current = cursor.current();
assert_eq!(current, (&10, &100));
Implementations§
Trait Implementations§
impl<'a, K: Sync, V: Sync> Send for Cursor<'a, K, V>
impl<'a, K: Sync, V: Sync> Sync for Cursor<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for Cursor<'a, K, V>
impl<'a, K, V> RefUnwindSafe for Cursor<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> Unpin for Cursor<'a, K, V>
impl<'a, K, V> UnwindSafe for Cursor<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes
slot. Read more