pub struct IntVector { /* private fields */ }Expand description
A contiguous growable and mutable bit-packed array of fixed-width integers.
This structure contains RawVector, which is in turn contains Vec.
Each item consists of the lowest 1 to 64 bits of a u64 value, as specified by parameter width.
The maximum length of the vector is usize::MAX / width items.
A default constructed IntVector has width == 64.
IntVector can be built from an iterator over u8, u16, u32, u64, or usize values.
IntVector implements the following simple_sds traits:
- Basic functionality:
Vector,Resize,Pack - Queries and operations:
Access,Push,Pop - Serialization:
Serialize
§Notes
IntVectornever panics from I/O errors.
Implementations§
Source§impl IntVector
impl IntVector
Sourcepub fn with_len(
len: usize,
width: usize,
value: u64,
) -> Result<IntVector, &'static str>
pub fn with_len( len: usize, width: usize, value: u64, ) -> Result<IntVector, &'static str>
Creates an initialized vector of specified length and width.
Returns Err if the width is invalid.
§Arguments
len: Number of items in the vector.width: Width of each item in bits.value: Initialization value.
§Examples
use simple_sds_sbwt::int_vector::IntVector;
use simple_sds_sbwt::ops::{Vector, Access};
let v = IntVector::with_len(4, 13, 1234).unwrap();
assert_eq!(v.len(), 4);
assert_eq!(v.width(), 13);
for i in 0..v.len() {
assert_eq!(v.get(i), 1234);
}§Panics
May panic if the vector would exceed the maximum length.
Sourcepub fn with_capacity(
capacity: usize,
width: usize,
) -> Result<IntVector, &'static str>
pub fn with_capacity( capacity: usize, width: usize, ) -> Result<IntVector, &'static str>
Creates an empty vector with enough capacity for at least the specified number of items of specified width.
Returns Err if the width is invalid.
§Arguments
capacity: Minimum capacity of the vector in items.width: Width of each item in bits.
§Examples
use simple_sds_sbwt::int_vector::IntVector;
use simple_sds_sbwt::ops::{Vector, Resize};
let v = IntVector::with_capacity(4, 13).unwrap();
assert!(v.is_empty());
assert_eq!(v.width(), 13);
assert!(v.capacity() >= 4);§Panics
May panic if the capacity would exceed the maximum length.
Sourcepub fn size_by_params(capacity: usize, width: usize) -> usize
pub fn size_by_params(capacity: usize, width: usize) -> usize
Returns the size of a serialized vector with the given parameters in u64 elements.
§Arguments
capacity: Minimum capacity of the vector in items.width: Width of each item in bits.
§Examples
use simple_sds_sbwt::int_vector::IntVector;
assert_eq!(IntVector::size_by_params(12, 31), 10);§Panics
May panic if the vector would exceed the maximum length.
Trait Implementations§
Source§impl<'a> Access<'a> for IntVector
impl<'a> Access<'a> for IntVector
Source§type Iter = AccessIter<'a, IntVector>
type Iter = AccessIter<'a, IntVector>
Source§fn get(&self, index: usize) -> <Self as Vector>::Item
fn get(&self, index: usize) -> <Self as Vector>::Item
Source§fn is_mutable(&self) -> bool
fn is_mutable(&self) -> bool
true if the underlying data is mutable. Read moreSource§impl Extend<u16> for IntVector
impl Extend<u16> for IntVector
Source§fn extend<I: IntoIterator<Item = u16>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u16>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<u32> for IntVector
impl Extend<u32> for IntVector
Source§fn extend<I: IntoIterator<Item = u32>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u32>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<u64> for IntVector
impl Extend<u64> for IntVector
Source§fn extend<I: IntoIterator<Item = u64>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u64>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<u8> for IntVector
impl Extend<u8> for IntVector
Source§fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<usize> for IntVector
impl Extend<usize> for IntVector
Source§fn extend<I: IntoIterator<Item = usize>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = usize>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)