Struct bittree::BitTree [−][src]
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]
fn clone(&self) -> BitTree<K, V>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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.
fn index(&self, index: &K) -> &Self::Output
[src]
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,
K: Unpin,
V: Unpin,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[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>,