[][src]Enum gf::support::bitpat::BitPatTableNode

pub enum BitPatTableNode<T> {
    Accept {
        value: T,
    Fork {
        prongs: Vec<BitPatTableNode<T>>,
    Dense {
        mask: u128,
        table: Vec<BitPatTableNode<T>>,
    Sparse {
        mask: u128,
        table: HashMap<u8, BitPatTableNode<T>>,

A node in the decision tree of a BitPatTable.

The normal way of dealing with pattern tables does not require to use this structure directly, use BitPatTableBuilder instead.



Accept node.

Fields of Accept

value: T

Associated value.


Reject node.


Internal fork node.

Fields of Fork

prongs: Vec<BitPatTableNode<T>>

Links to nodes to be considered in order.


Internal dense node.

Fields of Dense

mask: u128

Mask of bits that form the lookup key; the mask may have at most 8 set bits.

table: Vec<BitPatTableNode<T>>

Link table, has 2n items where n is the number of set bits in mask.


Internal sparse node.

Fields of Sparse

mask: u128

Mask of bits that form the lookup key; the mask may have at most 8 set bits.

table: HashMap<u8, BitPatTableNode<T>>

Link table; keys that have no values are assumed to be Reject.


impl<T> BitPatTableNode<T>[src]

pub fn get(&self, input: u128, input_bit_len: usize) -> Option<&T>[src]

Query the subtree for an input, returning Some for an Accept node, and None for a Reject node.


  • Panics if input_bit_len is greater than 128.

pub fn is_accept(&self) -> bool[src]

Return whether this is an Accept node.

pub fn is_reject(&self) -> bool[src]

Return whether this is a Reject node.

pub fn into_sparse(self) -> Self[src]

Recursively replace Dense nodes which have more Reject items than non-Reject items with Sparse nodes.

Trait Implementations

impl<T: Clone> Clone for BitPatTableNode<T>[src]

impl<T: Debug> Debug for BitPatTableNode<T>[src]

impl<T: Eq> Eq for BitPatTableNode<T>[src]

impl<T: PartialEq> PartialEq<BitPatTableNode<T>> for BitPatTableNode<T>[src]

impl<T> StructuralEq for BitPatTableNode<T>[src]

impl<T> StructuralPartialEq for BitPatTableNode<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for BitPatTableNode<T> where
    T: RefUnwindSafe

impl<T> Send for BitPatTableNode<T> where
    T: Send

impl<T> Sync for BitPatTableNode<T> where
    T: Sync

impl<T> Unpin for BitPatTableNode<T> where
    T: Unpin

impl<T> UnwindSafe for BitPatTableNode<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.