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]

[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);

[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);

[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);

[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 );

[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);

[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 );

[src]

The capacity of the bit-vector in bits.

[src]

The capacity of the bit-vector in blocks.

[src]

Adjust the capacity to hold at least additional additional bits.

May reserve more to avoid frequent reallocations.

[src]

Adjust the capacity to hold at least additional additional blocks.

May reserve more to avoid frequent reallocations.

[src]

Adjust the capacity to hold at least additional additional bits.

[src]

Adjusts the capacity to at least additional blocks beyond those used.

[src]

Shrinks the capacity of the vector as much as possible.

[src]

Converts the vector into Box<[Block]>.

Note that this will not drop any excess capacity.

[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.

[src]

Resizes the bit-vector, filling with value if it has to grow.

[src]

Gets a slice to a BV.

[src]

Gets a mutable slice to a BV.

[src]

Adds the given bool to the end of the bit-vector.

[src]

Removes and returnst the last element of the bit-vector, or None if empty.

[src]

Removes all elements from the bit-vector.

Does not change the capacity.

[src]

Does the bit-vector have no elements?

Trait Implementations

impl<Block: Clone> Clone for BV<Block>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<Block: BlockType> Default for BV<Block>
[src]

[src]

Returns the "default value" for a type. Read more

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

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

[src]

The length of the slice in bits.

[src]

The number of bits into the first block that the bit vector starts. Must be less than Block::nbits(). Read more

[src]

Gets the block at position Read more

[src]

The length of the slice in blocks.

[src]

Gets the bit at position Read more

[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]

[src]

Sets the block at position to value. Read more

[src]

Sets the bit at position to value. Read more

[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]

[src]

Adds the given bit to the end of the bit vector.

[src]

Removes and returns the last bit, if any.

[src]

Pushes value 0 or more times until the size of the bit vector is block-aligned. Read more

[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]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<Range<u64>> for &'a mut BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for &'a BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for &'a mut BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for &'a BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for &'a mut BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeFull> for &'a BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<'a, Block: BlockType> BitSliceable<RangeFull> for &'a mut BV<Block>
[src]

The type of the slice.

[src]

(Re-)slices the given object.

impl<Block: BlockType> Index<u64> for BV<Block>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<Block: BlockType> PartialEq for BV<Block>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<Block: BlockType> PartialOrd for BV<Block>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl<Block: BlockType + Hash> Hash for BV<Block>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<Block: BlockType> Debug for BV<Block>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<Block> Send for BV<Block> where
    Block: Send

impl<Block> Sync for BV<Block> where
    Block: Sync