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 to0
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]
impl<const WIDTH: u8> IntVector<WIDTH>
[src]pub fn new(size: usize, default_value: usize, width: Option<u8>) -> Result<Self>
[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 ifWIDTH == 0
.
pub fn set(&mut self, index: usize, value: usize)
[src]
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 bit_resize(&mut self, size: usize)
[src]
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 capacity(&self) -> usize
[src]
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 width(&self) -> u8
[src]
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]
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.
Trait Implementations
impl<const WIDTH: u8> IntoIterator for IntVector<WIDTH>
[src]
impl<const WIDTH: u8> IntoIterator for IntVector<WIDTH>
[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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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