pub trait BinInteger: Integer + Clone + Copy + Sized + AddAssign + SubAssign + MulAssign + DivAssign + Debug + Init + Zeroable + Send + Sync + ToPrimitive + TryFrom<usize> + 'static {
    type OneDigits: Iterator<Item = u32>;

    const BITS: u32;

    // Required methods
    fn ones(range: Range<u32>) -> Self;
    fn ones_truncated(range: Range<u32>) -> Self;
    fn trailing_zeros(&self) -> u32;
    fn leading_zeros(&self) -> u32;
    fn count_ones(&self) -> u32;
    fn bit_scan_forward(&self, start: u32) -> u32;
    fn extract_u32(&self, range: Range<u32>) -> u32;
    fn get_bit(&self, i: u32) -> bool;
    fn set_bit(&mut self, i: u32);
    fn clear_bit(&mut self, i: u32);
    fn checked_ceil_fix(self, fp: u32) -> Option<Self>;
    fn one_digits(&self) -> Self::OneDigits;
}
Expand description

Integral types with efficient binary operations.

Required Associated Types§

Required Associated Constants§

Required Methods§

source

fn ones(range: Range<u32>) -> Self

source

fn ones_truncated(range: Range<u32>) -> Self

source

fn trailing_zeros(&self) -> u32

Return the number of trailing zeros in its binary representation.

source

fn leading_zeros(&self) -> u32

Return the number of leading zeros in its binary representation.

source

fn count_ones(&self) -> u32

Return the number of ones in its binary representation.

source

fn bit_scan_forward(&self, start: u32) -> u32

Return the position of the least significant set bit since the position start.

Retruns Self::BITS if none was found.

source

fn extract_u32(&self, range: Range<u32>) -> u32

Slice a part of its binary representation as u32.

source

fn get_bit(&self, i: u32) -> bool

Retrieve whether the specified bit is set or not.

source

fn set_bit(&mut self, i: u32)

Set a single bit.

source

fn clear_bit(&mut self, i: u32)

Clear a single bit.

source

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

Perform ceil treating the value as a fixed point number with fp fractional part digits.

source

fn one_digits(&self) -> Self::OneDigits

Get an iterator over set bits, from the least significant bit to the most significant one.

Implementations on Foreign Types§

source§

impl BinInteger for i8

§

type OneDigits = OneDigits<i8>

source§

const BITS: u32 = 8u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for u128

§

type OneDigits = OneDigits<u128>

source§

const BITS: u32 = 128u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for u32

§

type OneDigits = OneDigits<u32>

source§

const BITS: u32 = 32u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for u8

§

type OneDigits = OneDigits<u8>

source§

const BITS: u32 = 8u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for i128

§

type OneDigits = OneDigits<i128>

source§

const BITS: u32 = 128u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for isize

§

type OneDigits = OneDigits<isize>

source§

const BITS: u32 = 64u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for u16

§

type OneDigits = OneDigits<u16>

source§

const BITS: u32 = 16u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for i16

§

type OneDigits = OneDigits<i16>

source§

const BITS: u32 = 16u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for i64

§

type OneDigits = OneDigits<i64>

source§

const BITS: u32 = 64u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for usize

§

type OneDigits = OneDigits<usize>

source§

const BITS: u32 = 64u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for i32

§

type OneDigits = OneDigits<i32>

source§

const BITS: u32 = 32u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

source§

impl BinInteger for u64

§

type OneDigits = OneDigits<u64>

source§

const BITS: u32 = 64u32

source§

fn ones(range: Range<u32>) -> Self

source§

fn ones_truncated(range: Range<u32>) -> Self

source§

fn trailing_zeros(&self) -> u32

source§

fn leading_zeros(&self) -> u32

source§

fn count_ones(&self) -> u32

source§

fn bit_scan_forward(&self, start: u32) -> u32

source§

fn extract_u32(&self, range: Range<u32>) -> u32

source§

fn get_bit(&self, i: u32) -> bool

source§

fn set_bit(&mut self, i: u32)

source§

fn clear_bit(&mut self, i: u32)

source§

fn checked_ceil_fix(self, fp: u32) -> Option<Self>

source§

fn one_digits(&self) -> Self::OneDigits

Implementors§