[][src]Struct succinct::IntVector

pub struct IntVector<Block: BlockType = usize> { /* fields omitted */ }

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 from 0 to 2.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]

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]

Returns the element at a given index, also given an arbitrary element size and bit offset.

This computes the location of the element_indexth 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]

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_indexth 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 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 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_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 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 max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<Block: PartialOrd + BlockType> PartialOrd<IntVector<Block>> for IntVector<Block>[src]

impl<Block: PartialEq + BlockType> PartialEq<IntVector<Block>> for IntVector<Block>[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?

impl<Block: Clone + BlockType> Clone for 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]

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

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

Auto Trait Implementations

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

impl<Block> Unpin for IntVector<Block> where
    Block: Unpin

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

impl<Block> UnwindSafe for IntVector<Block> where
    Block: UnwindSafe

impl<Block> RefUnwindSafe for IntVector<Block> where
    Block: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]