Trait bv::Bits [−][src]
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_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:
bit_len
andget_bit
orget_block
, since each is defined in terms of the other.
Note that get_block
in terms of get_bit
is inefficient, and thus
you should implement get_block
directly if possible.
Associated Types
Required Methods
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
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 bits that are not part of the bit vector.
The default implementation assembles a block by reading each of its bits. Consider it a slow reference implementation, and override it.
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
.
Implementations on Foreign Types
impl<'a, T: Bits + ?Sized> Bits for &'a T
[src]
impl<'a, T: Bits + ?Sized> Bits for &'a T
impl<'a, T: Bits + ?Sized> Bits for &'a mut T
[src]
impl<'a, T: Bits + ?Sized> Bits for &'a mut T
impl<Block: BlockType> Bits for Box<Bits<Block = Block>>
[src]
impl<Block: BlockType> Bits for Box<Bits<Block = Block>>
impl<Block: BlockType> Bits for Box<BitsMut<Block = Block>>
[src]
impl<Block: BlockType> Bits for Box<BitsMut<Block = Block>>
impl<Block: BlockType> Bits for [Block]
[src]
impl<Block: BlockType> Bits for [Block]
impl Bits for [bool]
[src]
impl Bits for [bool]
impl Bits for Vec<bool>
[src]
impl Bits for Vec<bool>
impl<Block: BlockType> Bits for [Block; 0]
[src]
impl<Block: BlockType> Bits for [Block; 0]
impl Bits for [bool; 0]
[src]
impl Bits for [bool; 0]
impl<Block: BlockType> Bits for [Block; 1]
[src]
impl<Block: BlockType> Bits for [Block; 1]
impl Bits for [bool; 1]
[src]
impl Bits for [bool; 1]
impl<Block: BlockType> Bits for [Block; 2]
[src]
impl<Block: BlockType> Bits for [Block; 2]
impl Bits for [bool; 2]
[src]
impl Bits for [bool; 2]
impl<Block: BlockType> Bits for [Block; 3]
[src]
impl<Block: BlockType> Bits for [Block; 3]
impl Bits for [bool; 3]
[src]
impl Bits for [bool; 3]
impl<Block: BlockType> Bits for [Block; 4]
[src]
impl<Block: BlockType> Bits for [Block; 4]
impl Bits for [bool; 4]
[src]
impl Bits for [bool; 4]
impl<Block: BlockType> Bits for [Block; 5]
[src]
impl<Block: BlockType> Bits for [Block; 5]
impl Bits for [bool; 5]
[src]
impl Bits for [bool; 5]
impl<Block: BlockType> Bits for [Block; 6]
[src]
impl<Block: BlockType> Bits for [Block; 6]
impl Bits for [bool; 6]
[src]
impl Bits for [bool; 6]
impl<Block: BlockType> Bits for [Block; 7]
[src]
impl<Block: BlockType> Bits for [Block; 7]
impl Bits for [bool; 7]
[src]
impl Bits for [bool; 7]
impl<Block: BlockType> Bits for [Block; 8]
[src]
impl<Block: BlockType> Bits for [Block; 8]
impl Bits for [bool; 8]
[src]
impl Bits for [bool; 8]
impl<Block: BlockType> Bits for [Block; 9]
[src]
impl<Block: BlockType> Bits for [Block; 9]
impl Bits for [bool; 9]
[src]
impl Bits for [bool; 9]
impl<Block: BlockType> Bits for [Block; 10]
[src]
impl<Block: BlockType> Bits for [Block; 10]
impl Bits for [bool; 10]
[src]
impl Bits for [bool; 10]
impl<Block: BlockType> Bits for [Block; 11]
[src]
impl<Block: BlockType> Bits for [Block; 11]
impl Bits for [bool; 11]
[src]
impl Bits for [bool; 11]
impl<Block: BlockType> Bits for [Block; 12]
[src]
impl<Block: BlockType> Bits for [Block; 12]
impl Bits for [bool; 12]
[src]
impl Bits for [bool; 12]
impl<Block: BlockType> Bits for [Block; 13]
[src]
impl<Block: BlockType> Bits for [Block; 13]
impl Bits for [bool; 13]
[src]
impl Bits for [bool; 13]
impl<Block: BlockType> Bits for [Block; 14]
[src]
impl<Block: BlockType> Bits for [Block; 14]
impl Bits for [bool; 14]
[src]
impl Bits for [bool; 14]
impl<Block: BlockType> Bits for [Block; 15]
[src]
impl<Block: BlockType> Bits for [Block; 15]
impl Bits for [bool; 15]
[src]
impl Bits for [bool; 15]
impl<Block: BlockType> Bits for [Block; 16]
[src]
impl<Block: BlockType> Bits for [Block; 16]
impl Bits for [bool; 16]
[src]
impl Bits for [bool; 16]
impl<Block: BlockType> Bits for [Block; 17]
[src]
impl<Block: BlockType> Bits for [Block; 17]
impl Bits for [bool; 17]
[src]
impl Bits for [bool; 17]
impl<Block: BlockType> Bits for [Block; 18]
[src]
impl<Block: BlockType> Bits for [Block; 18]
impl Bits for [bool; 18]
[src]
impl Bits for [bool; 18]
impl<Block: BlockType> Bits for [Block; 19]
[src]
impl<Block: BlockType> Bits for [Block; 19]
impl Bits for [bool; 19]
[src]
impl Bits for [bool; 19]
impl<Block: BlockType> Bits for [Block; 20]
[src]
impl<Block: BlockType> Bits for [Block; 20]
impl Bits for [bool; 20]
[src]
impl Bits for [bool; 20]
impl<Block: BlockType> Bits for [Block; 21]
[src]
impl<Block: BlockType> Bits for [Block; 21]
impl Bits for [bool; 21]
[src]
impl Bits for [bool; 21]
impl<Block: BlockType> Bits for [Block; 22]
[src]
impl<Block: BlockType> Bits for [Block; 22]
impl Bits for [bool; 22]
[src]
impl Bits for [bool; 22]
impl<Block: BlockType> Bits for [Block; 23]
[src]
impl<Block: BlockType> Bits for [Block; 23]
impl Bits for [bool; 23]
[src]
impl Bits for [bool; 23]
impl<Block: BlockType> Bits for [Block; 24]
[src]
impl<Block: BlockType> Bits for [Block; 24]
impl Bits for [bool; 24]
[src]
impl Bits for [bool; 24]
impl<Block: BlockType> Bits for [Block; 25]
[src]
impl<Block: BlockType> Bits for [Block; 25]
impl Bits for [bool; 25]
[src]
impl Bits for [bool; 25]
impl<Block: BlockType> Bits for [Block; 26]
[src]
impl<Block: BlockType> Bits for [Block; 26]
impl Bits for [bool; 26]
[src]
impl Bits for [bool; 26]
impl<Block: BlockType> Bits for [Block; 27]
[src]
impl<Block: BlockType> Bits for [Block; 27]
impl Bits for [bool; 27]
[src]
impl Bits for [bool; 27]
impl<Block: BlockType> Bits for [Block; 28]
[src]
impl<Block: BlockType> Bits for [Block; 28]
impl Bits for [bool; 28]
[src]
impl Bits for [bool; 28]
impl<Block: BlockType> Bits for [Block; 29]
[src]
impl<Block: BlockType> Bits for [Block; 29]
impl Bits for [bool; 29]
[src]
impl Bits for [bool; 29]
impl<Block: BlockType> Bits for [Block; 30]
[src]
impl<Block: BlockType> Bits for [Block; 30]
impl Bits for [bool; 30]
[src]
impl Bits for [bool; 30]
impl<Block: BlockType> Bits for [Block; 31]
[src]
impl<Block: BlockType> Bits for [Block; 31]
impl Bits for [bool; 31]
[src]
impl Bits for [bool; 31]
impl Bits for u8
[src]
impl Bits for u8
impl Bits for u16
[src]
impl Bits for u16
impl Bits for u32
[src]
impl Bits for u32
impl Bits for u64
[src]
impl Bits for u64
impl Bits for u128
[src]
impl Bits for u128
impl Bits for usize
[src]
impl Bits for usize
Implementors
impl<'a, Block: BlockType> Bits for BitSlice<'a, Block> type Block = Block;
impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block> type Block = Block;
impl<Block: BlockType> Bits for BitVec<Block> type Block = Block;
impl<T: Bits> Bits for BitSliceAdapter<T> type Block = T::Block;
impl<T: Bits> Bits for BitNot<T> type Block = T::Block;
impl<T, U> Bits for BitAnd<T, U> where
T: Bits,
U: Bits<Block = T::Block>, type Block = T::Block;impl<T, U> Bits for BitOr<T, U> where
T: Bits,
U: Bits<Block = T::Block>, type Block = T::Block;impl<T, U> Bits for BitXor<T, U> where
T: Bits,
U: Bits<Block = T::Block>, 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, usize) -> T::Block, type Block = T::Block;impl<Block: BlockType> Bits for BitFill<Block> type Block = Block;
impl<T, U> Bits for BitConcat<T, U> where
T: Bits,
U: Bits<Block = T::Block>, type Block = T::Block;impl<Block: BlockType> Bits for BoolAdapter<Block, Vec<bool>> type Block = Block;
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut Vec<bool>> type Block = Block;
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a mut [bool]> type Block = Block;
impl<'a, Block: BlockType> Bits for BoolAdapter<Block, &'a [bool]> type Block = Block;