Type Alias BEIntVec

Source
pub type BEIntVec<C> = IntVec<BE, BufBitWriter<BE, MemWordWriterVec<u64, Vec<u64>>>, C>;
Expand description

Big-endian variant of IntVec.

Aliased Type§

struct BEIntVec<C> { /* private fields */ }

Implementations§

Source§

impl<C: Codec<BE, BufBitWriter<BE, MemWordWriterVec<u64, Vec<u64>>>>> BEIntVec<C>
where C::Params: Copy,

Source

pub fn from_with_param( input: &[u64], k: usize, codec_param: C::Params, ) -> Result<Self, Box<dyn Error>>

Creates a new BEIntVec from a vector of unsigned 64-bit integers.

Values are encoded with the specified codec parameter.

§Arguments
  • input: The values to be compressed.
  • k: The sampling rate (every k-th value is stored as a sample).
  • codec_param: Parameters for the codec.
§Examples
use compressed_intvec::intvec::BEIntVec;
use compressed_intvec::codecs::ExpGolombCodec;

let input = vec![1, 5, 3, 1991, 42];
let intvec = BEIntVec::<ExpGolombCodec>::from_with_param(&input, 2, 3).unwrap();

let value = intvec.get(3);
assert_eq!(value, 1991);
Source

pub fn get(&self, index: usize) -> u64

Retrieves the value at the given index.

Panics if the index is out of bounds.

§Examples
use compressed_intvec::intvec::BEIntVec;
use compressed_intvec::codecs::GammaCodec;

let input = vec![1, 5, 3, 12, 42];
let intvec = BEIntVec::<GammaCodec>::from(&input, 2).unwrap();
let value = intvec.get(3);
assert_eq!(value, 12);
Source

pub fn into_vec(self) -> Vec<u64>

Returns the original vector of integers.

This operation is expensive as it requires decoding the entire bitstream.

§Examples
use compressed_intvec::intvec::BEIntVec;
use compressed_intvec::codecs::GammaCodec;

let input = vec![43, 12, 5, 1991, 42];
let intvec = BEIntVec::<GammaCodec>::from(&input, 2).unwrap();
let values = intvec.into_vec();
assert_eq!(values, input);
Source

pub fn iter(&self) -> BEIntVecIter<'_, C>

Returns an iterator over the decompressed integer values stored in this compressed vector.

The iterator decodes values on the fly and does not modify the underlying data.

§Example
use compressed_intvec::intvec::BEIntVec;
use compressed_intvec::codecs::GammaCodec;

let input = vec![1, 5, 3, 12, 42];
let intvec = BEIntVec::<GammaCodec>::from(&input, 2).unwrap();

// Iterate over the vector and print each value.
for (i, value) in intvec.iter().enumerate() {
    assert_eq!(value, input[i]);
}
Source

pub fn limbs(&self) -> Vec<u64>

Returns a clone of the internal bitstream data as a vector of 64-bit unsigned integers.

This can be used for debugging or low-level operations where access to the raw compressed limb data is required.

Source

pub fn len(&self) -> usize

Returns the number of integers stored in the compressed vector.

This value represents the total count of decompressed integers.

Source

pub fn get_sampling_rate(&self) -> usize

Returns the sampling rate used by the compressed vector.

Source

pub fn get_samples(&self) -> Vec<usize>

Returns the codec parameter used by the compressed vector.

Source

pub fn is_empty(&self) -> bool

Checks whether the compressed vector contains no elements.

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

Source§

impl<C: Codec<BE, BufBitWriter<BE, MemWordWriterVec<u64, Vec<u64>>>, Params = ()>> BEIntVec<C>

Convenience constructor for codecs with no extra runtime parameter.

Source

pub fn from(input: &[u64], k: usize) -> Result<Self, Box<dyn Error>>