Struct con_art_rust::Art
source · [−]pub struct Art { /* private fields */ }
Implementations
sourceimpl Art
impl Art
sourcepub fn get(&self, key: &usize, guard: &Guard) -> Option<usize>
pub fn get(&self, key: &usize, guard: &Guard) -> Option<usize>
Returns a copy of the value corresponding to the key.
Examples
use con_art_rust::Art;
let tree = Art::new();
let guard = tree.pin();
tree.insert(1, 42, &guard);
assert_eq!(tree.get(&1, &guard).unwrap(), 42);
sourcepub fn pin(&self) -> Guard
pub fn pin(&self) -> Guard
Enters an epoch. Note: this can be expensive, try to reuse it.
Examples
use con_art_rust::Art;
let tree = Art::new();
let guard = tree.pin();
sourcepub fn remove(&self, k: &usize, guard: &Guard)
pub fn remove(&self, k: &usize, guard: &Guard)
Removes key-value pair from the tree.
Examples
use con_art_rust::Art;
let tree = Art::new();
let guard = tree.pin();
tree.insert(1, 42, &guard);
tree.remove(&1, &guard);
assert!(tree.get(&1, &guard).is_none());
sourcepub fn insert(&self, k: usize, v: usize, guard: &Guard)
pub fn insert(&self, k: usize, v: usize, guard: &Guard)
Insert a key-value pair to the tree.
Examples
use con_art_rust::Art;
let tree = Art::new();
let guard = tree.pin();
tree.insert(1, 42, &guard);
assert_eq!(tree.get(&1, &guard).unwrap(), 42);
sourcepub fn range(
&self,
start: &usize,
end: &usize,
result: &mut [usize],
guard: &Guard
) -> Option<usize>
pub fn range(
&self,
start: &usize,
end: &usize,
result: &mut [usize],
guard: &Guard
) -> Option<usize>
Scan the tree with the range of [start, end], write the result to the
result
buffer.
It scans the length of result
or the number of the keys within the range, whichever is smaller;
returns the number of the keys scanned.
Examples
use con_art_rust::Art;
let tree = Art::new();
let guard = tree.pin();
tree.insert(1, 42, &guard);
let low_key = 1;
let high_key = 2;
let mut result = [0; 2];
let scanned = tree.range(&low_key, &high_key, &mut result, &guard);
assert_eq!(scanned.unwrap(), 1);
assert_eq!(result, [42, 0]);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Art
impl Send for Art
impl Sync for Art
impl Unpin for Art
impl UnwindSafe for Art
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more