Struct sdsl::IntVector[][src]

pub struct IntVector<const WIDTH: u8> { /* fields omitted */ }
Expand description

A generic vector for integers of width $ [1..64] $ bits.

This generic vector class can be used to generate a vector that contains integers of fixed width $ [1..64] $.

Arguments

  • WIDTH - Width of an integer. If set to 0 it is variable during runtime, otherwise fixed at compile time.

Example

let mut iv = sdsl::IntVector::<0>::new(5, 42, Some(64))?;
iv.bit_resize(2 * iv.width() as usize);

let result: Vec<_> = iv.iter().collect();
let expected = vec![42, 42];
assert_eq!(result, expected);

For further examples see here.

Implementations

impl<const WIDTH: u8> IntVector<WIDTH>[src]

pub fn new(size: usize, default_value: usize, width: Option<u8>) -> Result<Self>[src]

Construct a new integer vector.

Arguments

  • size - Number of elements.
  • default_value - Default values for elements initialization.
  • width - The width of each integer. Must be specified if WIDTH == 0.

pub fn from_file(path: &PathBuf) -> Result<Self>[src]

Load vector from file.

Arguments

  • path - File path.

pub fn get(&self, index: usize) -> usize[src]

Get the i-th element of the vector.

Arguments

  • index - An index in range $ [0, \mathrm{len}()) $.

pub fn set(&mut self, index: usize, value: usize)[src]

Set the i-th element of the vector.

Arguments

  • index - An index in range $ [0, \mathrm{len}()) $.
  • value - New element value.

pub fn is_empty(&self) -> bool[src]

Returns true if the vector is empty, otherwise returns false.

pub fn resize(&mut self, size: usize)[src]

Resize the vector in terms of elements.

Arguments

  • size - Target number of elements.

pub fn bit_resize(&mut self, size: usize)[src]

Resize the total vector in terms of bits.

Arguments

  • size - The size to resize the vector in terms of bits.

pub fn len(&self) -> usize[src]

The number of elements in the vector.

pub fn max_size(&self) -> usize[src]

Maximum size of the vector.

pub fn bit_size(&self) -> usize[src]

The number of bits in the vector.

pub fn capacity(&self) -> usize[src]

Returns the size of the occupied bits of the vector.

The capacity of a vector is greater or equal to the bit_size().

pub fn data(&self) -> *const c_void[src]

Constant pointer to the raw data of the vector.

pub fn width(&self) -> u8[src]

Returns the width of the integers which are accessed via the get(...) method.

pub fn set_width(&mut self, width: usize) -> Result<()>[src]

Sets the width of the integers which are accessed via the get(...) method, if WIDTH equals 0.

This function does not bit resize each element in the vector. Rather, after using this function, the raw data of the vector will be interpreted differently.

Arguments

  • width - New width of the integers.

pub fn iter(&self) -> VectorIterator<'_, Self>[src]

Returns an iterator over the vector values.

Trait Implementations

impl<const WIDTH: u8> Clone for IntVector<WIDTH>[src]

fn clone(&self) -> Self[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<const WIDTH: u8> Debug for IntVector<WIDTH>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<const WIDTH: u8> Drop for IntVector<WIDTH>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl<const WIDTH: u8> IO for IntVector<WIDTH>[src]

fn io(&self) -> &Interface[src]

impl<const WIDTH: u8> IntoIterator for IntVector<WIDTH>[src]

type Item = usize

The type of the elements being iterated over.

type IntoIter = VectorIntoIterator<IntVector<WIDTH>>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<const WIDTH: u8> Util for IntVector<WIDTH>[src]

fn util(&self) -> &Interface[src]

Auto Trait Implementations

impl<const WIDTH: u8> RefUnwindSafe for IntVector<WIDTH>

impl<const WIDTH: u8> !Send for IntVector<WIDTH>

impl<const WIDTH: u8> !Sync for IntVector<WIDTH>

impl<const WIDTH: u8> Unpin for IntVector<WIDTH>

impl<const WIDTH: u8> UnwindSafe for IntVector<WIDTH>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.