[−][src]Struct scc::TreeIndex
A scalable concurrent tree map implementation.
scc::TreeIndex is a B+ tree variant that is optimized for read operations. Read operations, such as scan, read, are neither blocked nor interrupted by all the other types of operations. Write operations, such as insert, remove, do not block if they do not entail structural changes to the tree.
Implementations
impl<K: Clone + Ord + Send + Sync, V: Clone + Send + Sync> TreeIndex<K, V>
[src]
pub fn new() -> TreeIndex<K, V>
[src]
Creates an empty TreeIndex instance.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = TreeIndex::new(); let result = treeindex.read(&1, |key, value| *value); assert!(result.is_none());
pub fn insert(&self, key: K, value: V) -> Result<(), (K, V)>
[src]
Inserts a a key-value pair.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = TreeIndex::new(); let result = treeindex.insert(1, 10); assert!(result.is_ok()); let result = treeindex.insert(1, 11); assert_eq!(result.err().unwrap(), (1, 11)); let result = treeindex.read(&1, |key, value| *value); assert_eq!(result.unwrap(), 10);
pub fn remove(&self, key: &K) -> bool
[src]
(work-in-progress) Removes a key-value pair.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = TreeIndex::new(); let result = treeindex.remove(&1); assert!(!result); let result = treeindex.insert(1, 10); assert!(result.is_ok()); let result = treeindex.remove(&1); assert!(result);
pub fn read<U, F: FnOnce(&K, &V) -> U>(&self, key: &K, f: F) -> Option<U>
[src]
Reads a key-value pair.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = TreeIndex::new(); let result = treeindex.read(&1, |key, value| *value); assert!(result.is_none()); let result = treeindex.insert(1, 10); assert!(result.is_ok()); let result = treeindex.read(&1, |key, value| *value); assert_eq!(result.unwrap(), 10);
pub fn iter(&self) -> Scanner<'_, K, V>ⓘ
[src]
Returns a Scanner.
The returned Scanner starts scanning from the minimum key-value pair.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = TreeIndex::new(); let result = treeindex.insert(1, 10); assert!(result.is_ok()); let result = treeindex.insert(2, 11); assert!(result.is_ok()); let result = treeindex.insert(3, 13); assert!(result.is_ok()); let mut scanner = treeindex.iter(); assert_eq!(scanner.next().unwrap(), (&1, &10)); assert_eq!(scanner.next().unwrap(), (&2, &11)); assert_eq!(scanner.next().unwrap(), (&3, &13)); assert!(scanner.next().is_none());
Trait Implementations
impl<K: Clone + Ord + Send + Sync, V: Clone + Send + Sync> Default for TreeIndex<K, V>
[src]
pub fn default() -> Self
[src]
Creates a TreeIndex instance with the default parameters.
Examples
use scc::TreeIndex; let treeindex: TreeIndex<u64, u32> = Default::default(); let result = treeindex.read(&1, |key, value| *value); assert!(result.is_none());
impl<K: Clone + Ord + Send + Sync, V: Clone + Send + Sync> Drop for TreeIndex<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for TreeIndex<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
[src]
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TreeIndex<K, V>
[src]
impl<K, V> Sync for TreeIndex<K, V>
[src]
impl<K, V> Unpin for TreeIndex<K, V>
[src]
impl<K, V> UnwindSafe for TreeIndex<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
[src]
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,