[go: up one dir, main page]

[][src]Struct scc::TreeIndex

pub struct TreeIndex<K: Clone + Ord + Send + Sync, V: Clone + Send + Sync> { /* fields omitted */ }

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> Drop for TreeIndex<K, V>[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for TreeIndex<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe
[src]

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]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.