Struct succinct::BitVec
[−]
[src]
pub struct BitVec<Block: BlockType = usize>(_);
A bit vector implementation.
Methods
impl<Block: BlockType> BitVec<Block>
[src]
fn new() -> Self
Creates a new, empty bit vector.
fn with_capacity(capacity: u64) -> Self
Creates a new, empty bit vector with space allocated for capacity
bits.
Panics
Panics if capacity
is too large. In particular the number of
blocks required by the capacity (capacity / Block::nbits()
)
must fit in a usize
.
fn block_with_capacity(capacity: usize) -> Self
Creates a new, empty bit vector with space allocated for capacity
blocks.
fn with_fill(len: u64, value: bool) -> Self
Creates a new bit vector of len
bits initialized to value
.
Panics
Panics if len
is too large. In particular the number of
blocks required by the capacity (len / Block::nbits()
)
must fit in a usize
.
fn block_with_fill(block_len: usize, value: Block) -> Self
Creates a new bit vector of block_len
blocks initialized to value
.
fn capacity(&self) -> u64
How many bits the bit vector can hold without reallocating.
fn block_capacity(&self) -> usize
How many blocks the bit vector can hold without reallocating.
fn resize(&mut self, new_len: u64, value: bool)
Resizes the bit vector to the given number of elements, filling if necessary.
Panics
Panics if new_len
is too large. In particular the number of
blocks required by the capacity (new_len / Block::nbits()
)
must fit in a usize
.
fn block_resize(&mut self, new_len: usize, value: Block)
Resizes the bit vector to the given number of blocks, filling if necessary.
fn reserve(&mut self, additional: u64)
Reserves capacity for at least additional
more bits to be
inserted.
The collection may reserve more space to avoid frequent reallocations.
Panics
Panics if the number of blocks overflows a usize
.
fn block_reserve(&mut self, additional: usize)
Reserves capacity for at least additional
blocks of bits to be
inserted.
The collection may reserve more space to avoid frequent reallocations.
Panics
Panics if the number of blocks overflows a usize
.
fn reserve_exact(&mut self, additional: u64)
Reserves capacity for at least additional
more bits to be
inserted.
Unlike reserve
, does nothing if the
capacity is already sufficient.
Panics
Panics if the number of blocks overflows a usize
.
fn block_reserve_exact(&mut self, additional: usize)
Reserves capacity for at least additional
more blocks of bits to be
inserted.
Unlike reserve_block
, does nothing if the
capacity is already sufficient.
Panics
Panics if the number of blocks overflows a usize
.
fn shrink_to_fit(&mut self)
Shrinks the capacity to just fit the number of elements.
fn truncate(&mut self, len: u64)
Shrinks to the given size.
Does nothing if len
is greater than the current size.
fn block_truncate(&mut self, block_len: usize)
Shrinks to the given size in blocks.
Does nothing if block_len
is greater than the current size in blocks.
fn clear(&mut self)
Sets the size to 0 while retaining the allocated storage.
fn iter(&self) -> Iter<Block>
Returns an iterator over the bits of the bit vector
Trait Implementations
impl<Block: Hash + BlockType> Hash for BitVec<Block>
[src]
fn hash<__HBlock: Hasher>(&self, __arg_0: &mut __HBlock)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<Block: PartialOrd + BlockType> PartialOrd for BitVec<Block>
[src]
fn partial_cmp(&self, __arg_0: &BitVec<Block>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &BitVec<Block>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &BitVec<Block>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &BitVec<Block>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &BitVec<Block>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<Block: Ord + BlockType> Ord for BitVec<Block>
[src]
fn cmp(&self, __arg_0: &BitVec<Block>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<Block: PartialEq + BlockType> PartialEq for BitVec<Block>
[src]
fn eq(&self, __arg_0: &BitVec<Block>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BitVec<Block>) -> bool
This method tests for !=
.
impl<Block: Eq + BlockType> Eq for BitVec<Block>
[src]
impl<Block: Debug + BlockType> Debug for BitVec<Block>
[src]
impl<Block: Clone + BlockType> Clone for BitVec<Block>
[src]
fn clone(&self) -> BitVec<Block>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<Block: BlockType> Bits for BitVec<Block>
[src]
type Block = Block
The underlying block type used to store the bits of the slice.
fn bit_len(&self) -> u64
The length of the slice in bits.
fn get_bit(&self, index: u64) -> bool
Gets the bit at position
Read more
fn get_block(&self, index: usize) -> Block
Gets the block at position
Read more
fn block_len(&self) -> usize
The length of the slice in blocks.
fn get_bits(&self, start: u64, count: usize) -> Self::Block
Gets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
impl<Block: BlockType> BitsMut for BitVec<Block>
[src]
fn set_bit(&mut self, index: u64, value: bool)
Sets the bit at position
to value
. Read more
fn set_block(&mut self, index: usize, value: Block)
Sets the block at position
to value
. Read more
fn set_bits(&mut self, start: u64, count: usize, value: Self::Block)
Sets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
impl<Block: BlockType> BitVector for BitVec<Block>
[src]
fn push_bit(&mut self, value: bool)
Adds the given bit to the end of the bit vector.
fn pop_bit(&mut self) -> Option<bool>
Removes and returns the last bit, if any.
fn push_block(&mut self, value: Block)
Pushes the given block onto the end of the bit vector. Read more
fn align_block(&mut self, value: bool)
Pushes value
0 or more times until the size of the bit vector is block-aligned. Read more
impl<Block: BlockType> Binary for BitVec<Block>
[src]
impl<Block: BlockType> SpaceUsage for BitVec<Block>
[src]
fn is_stack_only() -> bool
Is the size of this type known statically? Read more
fn heap_bytes(&self) -> usize
Calculates the heap portion of the size of an object. Read more
fn total_bytes(&self) -> usize
Computes the size of the receiver in bytes. Read more
fn stack_bytes() -> usize
Calculates the stack portion of the size of this type. Read more