Struct IntVec

Source
pub struct IntVec<E: Endianness, W: BitWrite<E>, C: Codec<E, W>> { /* private fields */ }
Expand description

A compressed vector of integers.

The IntVec stores values in a compressed bitstream along with sample offsets for fast random access. The type is generic over an endianness (E) and codec (C).

§Type Parameters

§Fields

  • data: The compressed bitstream data.
  • samples: Offsets (in bits) into data for every k-th value, used to jump-start decoding.
  • k: The sampling period.
  • len: The total number of integers stored.
  • codec_param: Extra parameters for C.

§Examples

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

// Create a compressed vector using a codec without extra parameters.
let input = vec![1, 2, 3, 4, 5];
let intvec = BEIntVec::<GammaCodec>::from(&input, 2).unwrap();
let value = intvec.get(3);
assert_eq!(value, 4);
assert_eq!(intvec.len(), 5);

Implementations§

Source§

impl<C: Codec<BE, BufBitWriter<BE, MemWordWriterVec<u64, Vec<u64>>>>> IntVec<BigEndian, BufBitWriter<BigEndian, MemWordWriterVec<u64, Vec<u64>>>, 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 = ()>> IntVec<BigEndian, BufBitWriter<BigEndian, MemWordWriterVec<u64, Vec<u64>>>, C>

Convenience constructor for codecs with no extra runtime parameter.

Source

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

Source§

impl<C> IntVec<LittleEndian, BufBitWriter<LittleEndian, MemWordWriterVec<u64, Vec<u64>>>, C>

Source

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

Creates a new LEIntVec 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::LEIntVec;
use compressed_intvec::codecs::ExpGolombCodec;

let input = vec![1, 5, 3, 1991, 42];
let intvec = LEIntVec::<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.

Returns None if the index is out of bounds.

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

let input = vec![1, 5, 3, 1991, 42];
let intvec = LEIntVec::<GammaCodec>::from(&input, 2).unwrap();
let value = intvec.get(3);
assert_eq!(value, 1991);
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::LEIntVec;
use compressed_intvec::codecs::GammaCodec;

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

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

Returns an iterator over the values stored in the vector.

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<LE, BufBitWriter<LE, MemWordWriterVec<u64, Vec<u64>>>, Params = ()>> IntVec<LittleEndian, BufBitWriter<LittleEndian, MemWordWriterVec<u64, Vec<u64>>>, C>

Convenience constructor for codecs with no extra runtime parameter.

Source

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

Trait Implementations§

Source§

impl<E: Clone + Endianness, W: Clone + BitWrite<E>, C: Clone + Codec<E, W>> Clone for IntVec<E, W, C>
where C::Params: Clone,

Source§

fn clone(&self) -> IntVec<E, W, C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Endianness, W: BitWrite<E>, C: Codec<E, W>> CopyType for IntVec<E, W, C>

Source§

impl<E: Debug + Endianness, W: Debug + BitWrite<E>, C: Debug + Codec<E, W>> Debug for IntVec<E, W, C>
where C::Params: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<E: Endianness, W: BitWrite<E>, C: Codec<E, W>> MemDbgImpl for IntVec<E, W, C>

Source§

fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, ) -> Result

Source§

impl<E: Endianness, W: BitWrite<E>, C: Codec<E, W>> MemSize for IntVec<E, W, C>

Source§

fn mem_size(&self, _memsize_flags: SizeFlags) -> usize

Return the (recursively computed) overall memory size of the structure in bytes.

Auto Trait Implementations§

§

impl<E, W, C> Freeze for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: Freeze,

§

impl<E, W, C> RefUnwindSafe for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: RefUnwindSafe, C: RefUnwindSafe, E: RefUnwindSafe,

§

impl<E, W, C> Send for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: Send, C: Send, E: Send,

§

impl<E, W, C> Sync for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: Sync, C: Sync, E: Sync,

§

impl<E, W, C> Unpin for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: Unpin, C: Unpin, E: Unpin,

§

impl<E, W, C> UnwindSafe for IntVec<E, W, C>
where <C as Codec<E, W>>::Params: UnwindSafe, C: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MemDbg for T
where T: MemDbgImpl,

Source§

fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>

Write to stdout debug infos about the structure memory usage, expanding all levels of nested structures.
Source§

fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>

Write to a core::fmt::Write debug infos about the structure memory usage, expanding all levels of nested structures.
Source§

fn mem_dbg_depth( &self, total_size: usize, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>

Write to stdout debug infos about the structure memory usage, but expanding only up to max_depth levels of nested structures.
Source§

fn mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, flags: DbgFlags, ) -> Result<(), Error>

Write to a core::fmt::Write debug infos about the structure memory usage, but expanding only up to max_depth levels of nested structures.
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V