Struct bittree::BitTree[][src]

pub struct BitTree<K: GetBytes, V: GetBytes> { /* fields omitted */ }

This is the main data structure that the crate contains. It consists of a tree of bits that is specifically meant for an O(1) find function. It has slow indexing, pushes, and removals, however, and so is mainly useful for seldom changed datasets that are searched consistently.

Example usage:

use bittree::BitTree;
let mut btree = BitTree::new();
btree.add(&0usize, Some(0usize));
assert_eq!(btree.find(&0usize), Some(0usize));
 
btree.remove(&0usize);
assert_eq!(btree.find(&0usize), None);

Implementations

impl<K: GetBytes, V: GetBytes> BitTree<K, V>[src]

pub fn new() -> BitTree<K, V>[src]

This creates a new BitTree.

pub fn add(&mut self, key: &K, value: Option<V>)[src]

To add to the bittree, this function gets all of the bits of the input data and creates new entries for each non-existent part of the path of bits until it completes the bitpath. It adds a new value at the last entry.

pub fn remove(&mut self, key: &K)[src]

To remove from the tree of bits, this function gets the second to last entry for the input data and removes the child entry used for the data.

pub fn find(&mut self, value: &V) -> Option<K>[src]

To search through the data and find a value, this function checks if all of the required bit entries specified in the bitpath exist in the values-to-keys bitpath, which solely depends on the size of the data being searched for (a constant, hence constant time) rather than the size of the dataset.

Trait Implementations

impl<K: Clone + GetBytes, V: Clone + GetBytes> Clone for BitTree<K, V>[src]

impl<K: Debug + GetBytes, V: Debug + GetBytes> Debug for BitTree<K, V>[src]

impl<K: GetBytes, V: GetBytes> Default for BitTree<K, V>[src]

impl<K: GetBytes, V: GetBytes> GetBytes for BitTree<K, V>[src]

impl<K: GetBytes, V: GetBytes> Index<&'_ K> for BitTree<K, V>[src]

type Output = Option<V>

The returned type after indexing.

impl<K: GetBytes, V: GetBytes> IndexMut<&'_ K> for BitTree<K, V>[src]

Auto Trait Implementations

impl<K, V> !Send for BitTree<K, V>

impl<K, V> !Sync for BitTree<K, V>

impl<K, V> Unpin for BitTree<K, V> where
    K: Unpin,
    V: Unpin

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.