[][src]Trait bv::Bits

pub trait Bits {
    type Block: BlockType;
    fn bit_len(&self) -> u64;

    fn block_len(&self) -> usize { ... }
fn get_bit(&self, position: u64) -> bool { ... }
fn get_block(&self, position: usize) -> Self::Block { ... }
fn get_raw_block(&self, position: usize) -> Self::Block { ... }
fn get_bits(&self, start: u64, count: usize) -> Self::Block { ... }
fn to_bit_vec(&self) -> BitVec<Self::Block> { ... } }

Read-only bit vector operations.

Minimal complete definition is:

Note that get_block in terms of get_bit is inefficient, and thus you should implement get_block directly if possible.

Associated Types

type Block: BlockType

The underlying block type used to store the bits of the vector.

Loading content...

Required methods

fn bit_len(&self) -> u64

The length of the slice in bits.

Loading content...

Provided methods

fn block_len(&self) -> usize

The length of the slice in blocks.

fn get_bit(&self, position: u64) -> bool

Gets the bit at position

The default implementation calls get_block and masks out the correct bit.

Panics

Panics if position is out of bounds.

fn get_block(&self, position: usize) -> Self::Block

Gets the block at position, masked as necessary.

The bits are laid out Block::nbits() per block, with the notional zeroth bit in the least significant position. If self.bit_len() is not a multiple of Block::nbits() then the last block will contain extra zero bits that are not part of the bit vector.

The default implementation calls get_raw_block, but you can override with something more efficient, for example if masking is unnecessary.

Panics

Panics if position is out of bounds.

fn get_raw_block(&self, position: usize) -> Self::Block

Gets the block at position, without masking.

The default implementation of this method just delegates to [get_block](#method .get_block), which means it in fact does mask out extraneous bits. However, particular implementors may override this method to provide a more efficient implementation when one is possible.

Panics

Panics if position is out of bounds.

fn get_bits(&self, start: u64, count: usize) -> Self::Block

Gets count bits starting at bit index start, interpreted as a little-endian integer.

Panics

Panics if the bit span goes out of bounds.

fn to_bit_vec(&self) -> BitVec<Self::Block>

Copies the bits into a new allocated BitVec.

Loading content...

Implementations on Foreign Types

impl<'a, T: Bits + ?Sized> Bits for &'a T[src]

type Block = T::Block

impl<'a, T: Bits + ?Sized> Bits for &'a mut T[src]

type Block = T::Block

impl<Block: BlockType> Bits for Box<dyn Bits<Block = Block>>[src]

type Block = Block

impl<Block: BlockType> Bits for Box<dyn BitsMut<Block = Block>>[src]

type Block = Block

impl<Block: BlockType> Bits for [Block][src]

type Block = Block

impl<Block: BlockType> Bits for Vec<Block>[src]

type Block = Block

impl Bits for [bool][src]

type Block = u8

impl Bits for Vec<bool>[src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 0][src]

type Block = Block

impl Bits for [bool; 0][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 1][src]

type Block = Block

impl Bits for [bool; 1][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 2][src]

type Block = Block

impl Bits for [bool; 2][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 3][src]

type Block = Block

impl Bits for [bool; 3][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 4][src]

type Block = Block

impl Bits for [bool; 4][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 5][src]

type Block = Block

impl Bits for [bool; 5][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 6][src]

type Block = Block

impl Bits for [bool; 6][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 7][src]

type Block = Block

impl Bits for [bool; 7][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 8][src]

type Block = Block

impl Bits for [bool; 8][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 9][src]

type Block = Block

impl Bits for [bool; 9][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 10][src]

type Block = Block

impl Bits for [bool; 10][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 11][src]

type Block = Block

impl Bits for [bool; 11][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 12][src]

type Block = Block

impl Bits for [bool; 12][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 13][src]

type Block = Block

impl Bits for [bool; 13][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 14][src]

type Block = Block

impl Bits for [bool; 14][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 15][src]

type Block = Block

impl Bits for [bool; 15][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 16][src]

type Block = Block

impl Bits for [bool; 16][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 17][src]

type Block = Block

impl Bits for [bool; 17][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 18][src]

type Block = Block

impl Bits for [bool; 18][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 19][src]

type Block = Block

impl Bits for [bool; 19][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 20][src]

type Block = Block

impl Bits for [bool; 20][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 21][src]

type Block = Block

impl Bits for [bool; 21][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 22][src]

type Block = Block

impl Bits for [bool; 22][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 23][src]

type Block = Block

impl Bits for [bool; 23][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 24][src]

type Block = Block

impl Bits for [bool; 24][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 25][src]

type Block = Block

impl Bits for [bool; 25][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 26][src]

type Block = Block

impl Bits for [bool; 26][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 27][src]

type Block = Block

impl Bits for [bool; 27][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 28][src]

type Block = Block

impl Bits for [bool; 28][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 29][src]

type Block = Block

impl Bits for [bool; 29][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 30][src]

type Block = Block

impl Bits for [bool; 30][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 31][src]

type Block = Block

impl Bits for [bool; 31][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 32][src]

type Block = Block

impl Bits for [bool; 32][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 64][src]

type Block = Block

impl Bits for [bool; 64][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 128][src]

type Block = Block

impl Bits for [bool; 128][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 256][src]

type Block = Block

impl Bits for [bool; 256][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 512][src]

type Block = Block

impl Bits for [bool; 512][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 1024][src]

type Block = Block

impl Bits for [bool; 1024][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 2048][src]

type Block = Block

impl Bits for [bool; 2048][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 4096][src]

type Block = Block

impl Bits for [bool; 4096][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 8192][src]

type Block = Block

impl Bits for [bool; 8192][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 16384][src]

type Block = Block

impl Bits for [bool; 16384][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 32768][src]

type Block = Block

impl Bits for [bool; 32768][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 65536][src]

type Block = Block

impl Bits for [bool; 65536][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 131072][src]

type Block = Block

impl Bits for [bool; 131072][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 262144][src]

type Block = Block

impl Bits for [bool; 262144][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 524288][src]

type Block = Block

impl Bits for [bool; 524288][src]

type Block = u8

impl<Block: BlockType> Bits for [Block; 1048576][src]

type Block = Block

impl Bits for [bool; 1048576][src]

type Block = u8

impl Bits for u8[src]

type Block = u8

impl Bits for u16[src]

type Block = u16

impl Bits for u32[src]

type Block = u32

impl Bits for u64[src]

type Block = u64

impl Bits for u128[src]

type Block = u128

impl Bits for usize[src]

type Block = usize

Loading content...

Implementors

impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut Vec<bool>>[src]

type Block = Block

impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a [bool]>[src]

type Block = Block

impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut [bool]>[src]

type Block = Block

impl<'a, Block: BlockType> Bits for BitSlice<'a, Block>[src]

type Block = Block

impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block>[src]

type Block = Block

impl<Block: BlockType> Bits for BitFill<Block>[src]

type Block = Block

impl<Block: BlockType> Bits for BoolAdapter<Block, Vec<bool>>[src]

type Block = Block

impl<Block: BlockType> Bits for BitVec<Block>[src]

type Block = Block

impl<T, U> Bits for BitAnd<T, U> where
    T: Bits,
    U: Bits<Block = T::Block>, 
[src]

type Block = T::Block

impl<T, U> Bits for BitConcat<T, U> where
    T: Bits,
    U: Bits<Block = T::Block>, 
[src]

type Block = T::Block

impl<T, U> Bits for BitOr<T, U> where
    T: Bits,
    U: Bits<Block = T::Block>, 
[src]

type Block = T::Block

impl<T, U> Bits for BitXor<T, U> where
    T: Bits,
    U: Bits<Block = T::Block>, 
[src]

type Block = T::Block

impl<T, U, F> Bits for BitZip<T, U, F> where
    T: Bits,
    U: Bits<Block = T::Block>,
    F: Fn(T::Block, T::Block) -> T::Block
[src]

type Block = T::Block

impl<T: Bits> Bits for BitNot<T>[src]

type Block = T::Block

impl<T: Bits> Bits for BitSliceAdapter<T>[src]

type Block = T::Block

Loading content...