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

pub enum BitPatTableNode<T> {
    Accept {
        value: T,
    },
    Reject,
    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.

Variants

Accept

Accept node.

Fields of Accept

value: T

Associated value.

Reject

Reject node.

Fork

Internal fork node.

Fields of Fork

prongs: Vec<BitPatTableNode<T>>

Links to nodes to be considered in order.

Dense

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.

Sparse

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.

Implementations

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.

Errors

  • 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
[src]

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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.