EightValueLookup

Struct EightValueLookup 

Source
pub struct EightValueLookup { /* private fields */ }
Expand description

SIMD-accelerated position lookup for finding a u32 value in a table of up to 8 values

This is optimized for the common pattern of finding the index/position of a value in a small lookup table, which is more useful than simple membership testing.

Implementations§

Source§

impl EightValueLookup

Source

pub fn new(values: &[u32]) -> Self

Create a new position lookup table from a slice of u32 values

§Panics

Panics if more than 8 values are provided

Source

pub fn find_position(&self, value: u32) -> i32

Find the position of a u32 value in the lookup table Returns the position (0-7) if found, or -1 if not found

Source

pub fn find_positions_batch(&self, values: u32x8) -> [i32; 8]

Find positions for multiple values at once using SIMD Returns an array of positions where each element is the position (0-7) or -1

Source

pub fn len(&self) -> usize

Get the number of values in the lookup table

Source

pub fn is_empty(&self) -> bool

Check if the lookup table is empty

Source

pub fn as_array(&self) -> [u32; 8]

Get the underlying table as an array (includes padding zeros)

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.