[−][src]Struct succinct::IntVector
Uncompressed vector of k-bit unsigned integers.
The element width k is determined at vector creation time.
Block
gives the representation type. The element width k can
never exceed the number of bits in Block
.
Methods
impl<Block: BlockType> IntVector<Block>
[src]
pub fn new(element_bits: usize) -> Self
[src]
Creates a new integer vector.
Arguments
element_bits
— the size of each element in bits; hence elements range from0
to2.pow(element_bits) - 1
.
Result
The new, empty integer vector.
pub fn with_capacity(element_bits: usize, capacity: u64) -> Self
[src]
Creates a new, empty integer vector, allocating sufficient storage
for capacity
elements.
pub fn block_with_capacity(element_bits: usize, block_capacity: usize) -> Self
[src]
Creates a new, empty integer vector, allocating block_capacity
blocks of storage.
pub fn with_fill(element_bits: usize, len: u64, value: Block) -> Self
[src]
Creates a new integer vector containing len
copies of value
.
pub fn block_with_fill(
element_bits: usize,
block_len: usize,
value: Block
) -> Self
[src]
element_bits: usize,
block_len: usize,
value: Block
) -> Self
Creates a new integer vector containing block_len
copies of the
block value
.
The length of the new vector will be the number of elements of size
element_bits
that fit in block_len
blocks.
pub fn get_random(
&self,
bit_offset: u64,
element_bits: usize,
element_index: u64
) -> Block
[src]
&self,
bit_offset: u64,
element_bits: usize,
element_index: u64
) -> Block
Returns the element at a given index, also given an arbitrary element size and bit offset.
This computes the location of the element_index
th element
supposing that elements are element_bits
side, then adds
bit_offset
additional bits and returns the element_bits
-bit
value found at that location.
Panics
Panics if the referenced bits are out of bounds. Bounds are
considered to the end of the support array, even if that goes
past the last element of the IntArray
.
pub fn set_random(
&mut self,
bit_offset: u64,
element_bits: usize,
element_index: u64,
element_value: Block
)
[src]
&mut self,
bit_offset: u64,
element_bits: usize,
element_index: u64,
element_value: Block
)
Sets the element at a given index to a given value, also given an arbitrary element size and bit offset.
This computes the location of the element_index
th element
supposing that elements are element_bits
side, then adds
bit_offset
additional bits and modifies the element_bits
-bit
value found at that location.
Panics
-
Panics if the referenced bits are out of bounds. Bounds are considered to the end of the support array, even if that goes past the last element of the
IntArray
. -
Debug mode only: Panics if
element_value
is too large to fit in the element size. (TODO: What’s the right thing here?)
pub fn push(&mut self, element_value: Block)
[src]
Pushes an element onto the end of the vector, increasing the length by 1.
pub fn pop(&mut self) -> Option<Block>
[src]
Removes and returns the last element of the vector, if present.
pub fn capacity(&self) -> u64
[src]
The number of elements the vector can hold without reallocating.
pub fn block_capacity(&self) -> usize
[src]
The number of blocks of elements the vector can hold without reallocating.
pub fn resize(&mut self, n_elements: u64, fill: Block)
[src]
Resizes to the given number of elements, filling if necessary.
pub fn block_resize(&mut self, n_blocks: usize, fill: Block)
[src]
Resizes to the given number of blocks, filling if necessary.
pub fn reserve(&mut self, additional: u64)
[src]
Reserves capacity for at least additional
more elements to be
inserted in the given IntVector<Block>
.
The collection may reserve more space to avoid frequent reallocations.
Panics
Panics if the size conditions of
IntVector::<Block>::is_okay_size()
are not met. This will happen if the total number of bits
overflows u64
.
pub fn block_reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
blocks of values to be
inserted.
The collection may reserve more space to avoid frequent reallocations.
Panics
Panics if the number of blocks overflows a usize
.
pub fn reserve_exact(&mut self, additional: u64)
[src]
Reserves capacity for at least additional
more elements to be
inserted in the given IntVector<Block>
.
Unlike reserve
, does nothing if the
capacity is already sufficient.
Panics
Panics if the size conditions of
IntVector::<Block>::is_okay_size()
are not met. This will happen if the total number of bits
overflows u64
.
pub fn block_reserve_exact(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
blocks of values to be
inserted.
Unlike reserve_block
, does nothing if the
capacity is already sufficient.
The collection may reserve more space to avoid frequent reallocations.
Panics
Panics if the number of blocks overflows a usize
.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity to just fit the number of elements.
pub fn truncate(&mut self, n_elements: u64)
[src]
Shrinks to the given size.
Does nothing if n_elements
is greater than the current size.
pub fn block_truncate(&mut self, n_blocks: usize)
[src]
Shrinks to the given number of blocks.
Does nothing if n_blocks
is greater than the current blocks.
pub fn clear(&mut self)
[src]
Sets the size to 0 while retaining the allocated storage.
ⓘImportant traits for Iter<'a, Block>pub fn iter(&self) -> Iter<Block>
[src]
Gets an iterator over the elements of the vector.
pub fn is_block_sized(&self) -> bool
[src]
True if the element size matches the block size.
pub fn is_aligned(&self) -> bool
[src]
True if elements are aligned within blocks.
Trait Implementations
impl<A: BlockType> SpaceUsage for IntVector<A>
[src]
fn is_stack_only() -> bool
[src]
fn heap_bytes(&self) -> usize
[src]
fn total_bytes(&self) -> usize
[src]
Computes the size of the receiver in bytes. Read more
fn stack_bytes() -> usize
[src]
Calculates the stack portion of the size of this type. Read more
impl<Block: BlockType> BitVec for IntVector<Block>
[src]
type Block = Block
The underlying block type used to store the bits of the vector.
fn block_len(&self) -> usize
[src]
fn bit_len(&self) -> u64
[src]
fn get_block(&self, position: usize) -> Block
[src]
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 IntVector<Block>
[src]
fn set_block(&mut self, position: usize, value: Block)
[src]
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> IntVec for IntVector<Block>
[src]
type Block = Block
The type of primitive value to represent elements.
fn len(&self) -> u64
[src]
fn get(&self, element_index: u64) -> Block
[src]
fn element_bits(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
Is the vector empty?
impl<Block: BlockType> IntVecMut for IntVector<Block>
[src]
impl<Block: Ord + BlockType> Ord for IntVector<Block>
[src]
fn cmp(&self, other: &IntVector<Block>) -> Ordering
[src]
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
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl<Block: PartialOrd + BlockType> PartialOrd<IntVector<Block>> for IntVector<Block>
[src]
fn partial_cmp(&self, other: &IntVector<Block>) -> Option<Ordering>
[src]
fn lt(&self, other: &IntVector<Block>) -> bool
[src]
fn le(&self, other: &IntVector<Block>) -> bool
[src]
fn gt(&self, other: &IntVector<Block>) -> bool
[src]
fn ge(&self, other: &IntVector<Block>) -> bool
[src]
impl<Block: PartialEq + BlockType> PartialEq<IntVector<Block>> for IntVector<Block>
[src]
fn eq(&self, other: &IntVector<Block>) -> bool
[src]
fn ne(&self, other: &IntVector<Block>) -> bool
[src]
impl<'a, Block: BlockType + 'a> IntoIterator for &'a IntVector<Block>
[src]
type Item = Block
The type of the elements being iterated over.
type IntoIter = Iter<'a, Block>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<Block: Clone + BlockType> Clone for IntVector<Block>
[src]
fn clone(&self) -> IntVector<Block>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<Block: Eq + BlockType> Eq for IntVector<Block>
[src]
impl<Block> Debug for IntVector<Block> where
Block: BlockType + Debug,
[src]
Block: BlockType + Debug,
impl<Block: Hash + BlockType> Hash for IntVector<Block>
[src]
Auto Trait Implementations
impl<Block> Send for IntVector<Block> where
Block: Send,
Block: Send,
impl<Block> Unpin for IntVector<Block> where
Block: Unpin,
Block: Unpin,
impl<Block> Sync for IntVector<Block> where
Block: Sync,
Block: Sync,
impl<Block> RefUnwindSafe for IntVector<Block> where
Block: RefUnwindSafe,
Block: RefUnwindSafe,
impl<Block> UnwindSafe for IntVector<Block> where
Block: UnwindSafe,
Block: UnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,