Struct bv::BV
[−]
[src]
pub struct BV<Block = usize> { /* fields omitted */ }
A bit-vector, akin to Vec<bool>
but packed.
Methods
impl<Block: BlockType> BV<Block>
[src]
pub fn new() -> Self
[src]
Creates a new, empty bit-vector of one block.
Examples
use bv::{BV, BitVec}; let mut bv: BV = BV::new(); assert_eq!(bv.len(), 0); bv.push(true); bv.push(false); bv.push(true); assert_eq!(bv.len(), 3); assert_eq!(bv.get_bit(0), true); assert_eq!(bv.get_bit(1), false); assert_eq!(bv.get_bit(2), true);
pub fn with_capacity(nbits: u64) -> Self
[src]
Creates a new, empty bit-vector with the given bit capacity.
Examples
use bv::BV; let mut bv: BV<u16> = BV::with_capacity(20); assert_eq!(bv.capacity(), 32);
pub fn with_block_capacity(nblocks: usize) -> Self
[src]
Creates a new, empty bit-vector with the given block capacity.
Examples
use bv::BV; let mut bv: BV<u16> = BV::with_block_capacity(8); assert_eq!(bv.capacity(), 128);
pub fn new_fill(value: bool, len: u64) -> Self
[src]
Creates a new bit-vector of size len
, filled with all 0s or 1s
depending on value
.
Examples
use bv::*; let mut bv: BV<u64> = BV::new_fill(false, 100); assert_eq!( bv.get_bit(0), false ); assert_eq!( bv.len(), 100 );
pub fn len(&self) -> u64
[src]
The number of bits in the bit-vector.
Examples
use bv::BV; let mut bv: BV = BV::new(); assert_eq!(bv.len(), 0); bv.push(false); assert_eq!(bv.len(), 1); bv.push(false); assert_eq!(bv.len(), 2); bv.push(false); assert_eq!(bv.len(), 3);
pub fn block_len(&self) -> usize
[src]
The number of blocks used by this bit-vector.
Examples
use bv::*; let mut bv: BV<u64> = BV::new_fill(false, 100); assert_eq!( bv.len(), 100 ); assert_eq!( bv.block_len(), 2 );
pub fn capacity(&self) -> u64
[src]
The capacity of the bit-vector in bits.
pub fn block_capacity(&self) -> usize
[src]
The capacity of the bit-vector in blocks.
pub fn reserve(&mut self, additional: u64)
[src]
Adjust the capacity to hold at least additional
additional bits.
May reserve more to avoid frequent reallocations.
pub fn block_reserve(&mut self, additional: usize)
[src]
Adjust the capacity to hold at least additional
additional blocks.
May reserve more to avoid frequent reallocations.
pub fn reserve_exact(&mut self, additional: u64)
[src]
Adjust the capacity to hold at least additional
additional bits.
pub fn block_reserve_exact(&mut self, additional: usize)
[src]
Adjusts the capacity to at least additional
blocks beyond those used.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the vector as much as possible.
pub fn into_boxed_slice(self) -> Box<[Block]>
[src]
Converts the vector into Box<[Block]>
.
Note that this will not drop any excess capacity.
pub fn truncate(&mut self, len: u64)
[src]
Shortens the vector, keeping the first len
elements and dropping the rest.
If len
is greater than the vector's current length, this has no effect.
Note that this method has no effect on the capacity of the bit-vector.
pub fn resize(&mut self, len: u64, value: bool)
[src]
Resizes the bit-vector, filling with value
if it has to grow.
pub fn as_slice(&self) -> BitSlice<Block>
[src]
Gets a slice to a BV
.
pub fn as_mut_slice(&mut self) -> BitSliceMut<Block>
[src]
Gets a mutable slice to a BV
.
pub fn push(&mut self, value: bool)
[src]
Adds the given bool
to the end of the bit-vector.
pub fn pop(&mut self) -> Option<bool>
[src]
Removes and returnst the last element of the bit-vector, or None
if empty.
pub fn clear(&mut self)
[src]
Removes all elements from the bit-vector.
Does not change the capacity.
pub fn is_empty(&self) -> bool
[src]
Does the bit-vector have no elements?
Trait Implementations
impl<Block: Clone> Clone for BV<Block>
[src]
fn clone(&self) -> BV<Block>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<Block: BlockType> Default for BV<Block>
[src]
impl<Block: BlockType> BitVec for BV<Block>
[src]
type Block = Block
The underlying block type used to store the bits of the vector.
fn bit_len(&self) -> u64
[src]
The length of the slice in bits.
fn bit_offset(&self) -> u8
[src]
The number of bits into the first block that the bit vector starts. Must be less than Block::nbits()
. Read more
fn get_block(&self, position: usize) -> Block
[src]
Gets the block at position
Read more
fn block_len(&self) -> usize
[src]
The length of the slice in blocks.
fn get_bit(&self, position: u64) -> bool
[src]
Gets the bit at position
Read more
fn get_bits(&self, start: u64, count: usize) -> Self::Block
[src]
Gets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
impl<Block: BlockType> BitVecMut for BV<Block>
[src]
fn set_block(&mut self, position: usize, value: Block)
[src]
Sets the block at position
to value
. Read more
fn set_bit(&mut self, position: u64, value: bool)
[src]
Sets the bit at position
to value
. Read more
fn set_bits(&mut self, start: u64, count: usize, value: Self::Block)
[src]
Sets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
impl<Block: BlockType> BitVecPush for BV<Block>
[src]
fn push_bit(&mut self, value: bool)
[src]
Adds the given bit to the end of the bit vector.
fn pop_bit(&mut self) -> Option<bool>
[src]
Removes and returns the last bit, if any.
fn align_block(&mut self, value: bool)
[src]
Pushes value
0 or more times until the size of the bit vector is block-aligned. Read more
fn push_block(&mut self, value: Block)
[src]
Pushes the given block onto the end of the bit vector. Read more
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for &'a BV<Block>
[src]
type Slice = BitSlice<'a, Block>
The type of the slice.
fn bit_slice(self, range: Range<u64>) -> BitSlice<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for &'a mut BV<Block>
[src]
type Slice = BitSliceMut<'a, Block>
The type of the slice.
fn bit_slice(self, range: Range<u64>) -> BitSliceMut<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for &'a BV<Block>
[src]
type Slice = BitSlice<'a, Block>
The type of the slice.
fn bit_slice(self, range: RangeFrom<u64>) -> BitSlice<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for &'a mut BV<Block>
[src]
type Slice = BitSliceMut<'a, Block>
The type of the slice.
fn bit_slice(self, range: RangeFrom<u64>) -> BitSliceMut<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for &'a BV<Block>
[src]
type Slice = BitSlice<'a, Block>
The type of the slice.
fn bit_slice(self, range: RangeTo<u64>) -> BitSlice<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for &'a mut BV<Block>
[src]
type Slice = BitSliceMut<'a, Block>
The type of the slice.
fn bit_slice(self, range: RangeTo<u64>) -> BitSliceMut<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeFull> for &'a BV<Block>
[src]
type Slice = BitSlice<'a, Block>
The type of the slice.
fn bit_slice(self, _: RangeFull) -> BitSlice<'a, Block>
[src]
(Re-)slices the given object.
impl<'a, Block: BlockType> BitSliceable<RangeFull> for &'a mut BV<Block>
[src]
type Slice = BitSliceMut<'a, Block>
The type of the slice.
fn bit_slice(self, _: RangeFull) -> BitSliceMut<'a, Block>
[src]
(Re-)slices the given object.
impl<Block: BlockType> Index<u64> for BV<Block>
[src]
type Output = bool
The returned type after indexing.
fn index(&self, index: u64) -> &bool
[src]
Performs the indexing (container[index]
) operation.
impl<Block: BlockType> PartialEq for BV<Block>
[src]
fn eq(&self, other: &BV<Block>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<Block: BlockType> PartialOrd for BV<Block>
[src]
fn partial_cmp(&self, other: &BV<Block>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<Block: BlockType> Eq for BV<Block>
[src]
impl<Block: BlockType> Ord for BV<Block>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<Block: BlockType + Hash> Hash for BV<Block>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more