BitSearch

Trait BitSearch 

Source
pub trait BitSearch {
    // Required method
    fn find_first_set(&self, lower_bound: usize) -> Option<usize>;

    // Provided method
    fn find_set_in_range<R>(&self, range: R) -> Option<usize>
       where R: RangeBounds<usize> { ... }
}
Expand description

Search for set its.

Required Methods§

Source

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Searches for first bit set starting with lower_bound. Returns index of first bit set.

§Example
fn validate<S: BitSearch + BitSetLimit + BitTest>(set: &S, lower_bound: usize) {
  match set.find_first_set(lower_bound) {
    None => assert!((lower_bound..=S::MAX_SET_INDEX).all(|idx| !set.test(idx))),
    Some(idx) => {
      assert!(idx <= S::MAX_SET_INDEX);
      assert!((lower_bound..idx).all(|idx| !set.test(idx)));
      assert!(set.test(idx));
    }
  }
}

Provided Methods§

Source

fn find_set_in_range<R>(&self, range: R) -> Option<usize>
where R: RangeBounds<usize>,

Searches for bit set specified range. Returns index of bit set.

§Example
fn validate<S: BitSearch + BitTest>(set: &S, mut range: Range<usize>) {
  match set.find_set_in_range(range.clone()) {
    None => assert!(range.all(|idx| !set.test(idx))),
    Some(idx) => {
      assert!(idx < range.end);
      assert!((range.start..idx).all(|idx| !set.test(idx)));
      assert!(set.test(idx));
    }
  }
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BitSearch for bool

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl BitSearch for u8

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl BitSearch for u16

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl BitSearch for u32

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl BitSearch for u64

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl BitSearch for u128

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<T> BitSearch for Option<T>
where T: BitSearch,

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<T> BitSearch for &T
where T: BitSearch,

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<T> BitSearch for &mut T
where T: BitSearch,

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<T> BitSearch for Box<T>
where T: BitSearch,

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<const N: usize> BitSearch for [u8; N]

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<const N: usize> BitSearch for [u16; N]

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<const N: usize> BitSearch for [u32; N]

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<const N: usize> BitSearch for [u64; N]

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Source§

impl<const N: usize> BitSearch for [u128; N]

Source§

fn find_first_set(&self, lower_bound: usize) -> Option<usize>

Implementors§

Source§

impl<T> BitSearch for Complement<Complement<T>>
where T: BitSearch,

Source§

impl<T, B, const N: usize> BitSearch for Layered<T, B, N>

Source§

impl<T, U> BitSearch for Difference<T, U>
where T: BitSearch, U: BitTest,

Source§

impl<T, U> BitSearch for Intersection<T, U>
where T: BitSearch, U: BitSearch,

Source§

impl<T, U> BitSearch for Union<T, U>
where T: BitSearch, U: BitSearch,