Skip to main content

CompIntList

Struct CompIntList 

Source
pub struct CompIntList<B: Backend = BitVec<Box<[usize]>>, D = EfSeq<u64>> { /* private fields */ }
Expand description

A compact list of integers not less than a given lower bound.

Each value x is stored as xmin + 1 (a strictly positive integer) by concatenating binary representations with the most significant bit removed. The boundaries between values are recorded in a SliceByValue<Value = u64> (by default an Elias–Fano sequence), enabling efficient random access.

After construction, the delimiter structure can be replaced using map_delimiters, and the data structure using map_data.

This structure implements the TryIntoUnaligned trait, allowing it to be converted into (usually faster) structures using unaligned access.

§Type Parameters

  • B: The data backend. Must implement Backend and BitVecValueOps<B::Word>. Defaults to [BitVec<Box<[usize]>>].
  • D: The delimiter structure. Must implement SliceByValue<Value = u64>. Defaults to EfSeq<u64>.

Implementations§

Source§

impl<V: Word> CompIntList<BitVec<Box<[V]>>>

Source

pub fn new<I: ?Sized>(min: V, values: &I) -> Self
where for<'a> &'a I: IntoIterator<Item = &'a V>,

Creates a new CompIntList from a lower bound and a reference to a collection of values not less than min.

The collection is iterated twice: once to compute statistics (element count and total bit length), and once to build the delimiter and data structures.

§Panics

Panics if any value is less than min.

§Examples
let values = vec![1u64, 5, 10];
let list = CompIntList::new(1, &values);
assert_eq!(list.len(), 3);
assert_eq!(list.index_value(1), 5);
Source§

impl<B: Backend<Word: Word> + BitVecValueOps<B::Word>, D: SliceByValue<Value = u64>> CompIntList<B, D>

Source

pub unsafe fn map_delimiters<F, D2>(self, func: F) -> CompIntList<B, D2>
where F: FnOnce(D) -> D2, D2: SliceByValue<Value = u64>,

Replaces the delimiter structure.

§Safety

This method is unsafe because it is not possible to guarantee that the new delimiters return the same values as the old ones.

Source

pub unsafe fn map_data<F, B2>(self, func: F) -> CompIntList<B2, D>
where F: FnOnce(B) -> B2, B2: Backend<Word = B::Word> + BitVecValueOps<B2::Word>,

Replaces the data structure.

§Safety

This method is unsafe because it is not possible to guarantee that the new data returns the same values as the old one.

Source

pub fn into_inner(self) -> D

Returns the underlying delimiter structure.

Trait Implementations§

Source§

impl<B, D> AlignHash for CompIntList<B, D>
where usize: SerInner<SerType: AlignHash>, B::Word: SerInner<SerType: AlignHash>, D: SerInner<SerType: AlignHash>, B: SerInner<SerType: AlignHash> + Backend, bool: SerInner<SerType: AlignHash>,

Source§

fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)

Accumulates alignment information in hasher assuming to be positioned at offset_of.
Source§

fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)

Calls AlignHash::align_hash on a value.
Source§

impl<B: Clone + Backend, D: Clone> Clone for CompIntList<B, D>
where B::Word: Clone,

Source§

fn clone(&self) -> CompIntList<B, D>

Returns a duplicate 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<B: Backend, D> CopyType for CompIntList<B, D>

Source§

impl<B: Debug + Backend, D: Debug> Debug for CompIntList<B, D>
where B::Word: Debug,

Source§

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

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

impl<B, D> DeserInner for CompIntList<B, D>
where usize: DeserInner, B::Word: DeserInner, D: DeserInner, B: DeserInner + Backend, bool: DeserInner, for<'a> <B as DeserInner>::DeserType<'a>: Backend<Word = B::Word>, for<'__epserde_desertype> DeserType<'__epserde_desertype, B>: Backend,

Source§

type DeserType<'__epserde_desertype> = CompIntList<<B as DeserInner>::DeserType<'__epserde_desertype>, <D as DeserInner>::DeserType<'__epserde_desertype>>

The deserialization type associated with this type. It can be retrieved conveniently with the alias DeserType.
Source§

fn __check_covariance<'__long: '__short, '__short>( proof: CovariantProof<Self::DeserType<'__long>>, ) -> CovariantProof<Self::DeserType<'__short>>

Internal method for checking the covariance of DeserType. Read more
Source§

unsafe fn _deser_full_inner( backend: &mut impl ReadWithPos, ) -> Result<Self, Error>

Safety Read more
Source§

unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>( backend: &mut SliceWithPos<'deser_eps_inner_lifetime>, ) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>

Safety Read more
Source§

impl<'de, B, D> Deserialize<'de> for CompIntList<B, D>
where B: Deserialize<'de> + Backend, D: Deserialize<'de>, B::Word: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<B, D> FlatType for CompIntList<B, D>

Source§

impl<V: Word, D, D2: SliceByValue<Value = u64>> From<CompIntList<BitVecU<Box<[V]>>, D>> for CompIntList<BitVec<Box<[V]>>, D2>
where D: Into<D2>,

Source§

fn from(c: CompIntList<BitVecU<Box<[V]>>, D>) -> Self

Converts to this type from the input type.
Source§

impl<B, D> MemDbgImpl for CompIntList<B, D>

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, _memdbg_refs: &mut HashSet<usize>, ) -> Result

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, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ) -> Result<(), Error>

Source§

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

Internal implementation for depth display. Read more
Source§

impl<B, D> MemSize for CompIntList<B, D>

Source§

fn mem_size_rec( &self, _memsize_flags: SizeFlags, _memsize_refs: &mut HashMap<usize, usize>, ) -> usize

Recursive implementation that tracks visited references for deduplication. Read more
Source§

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

Returns the (recursively computed) overall memory size of the structure in bytes.
Source§

impl<B, D> SerInner for CompIntList<B, D>

Source§

const IS_ZERO_COPY: bool

Inner constant used by the derive macros to keep track recursively of whether the type satisfies the conditions for being zero-copy. It is checked at runtime against the trait implemented by the type, and if a ZeroCopy type has this constant set to false serialization will panic.
Source§

type SerType = CompIntList<<B as SerInner>::SerType, <D as SerInner>::SerType>

This is the type that will be written in the header of the file, and thus the type that will be deserialized. In most cases it is Self, but in some cases, as for references to slices, it is customized.
Source§

unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>

Serializes this structure using the given backend. Read more
Source§

impl<B, D> Serialize for CompIntList<B, D>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<B: Backend<Word: Word> + BitVecValueOps<B::Word>, D: SliceByValue<Value = u64>> SliceByValue for CompIntList<B, D>

Source§

type Value = <B as Backend>::Word

The type of the values in the slice.
Source§

fn len(&self) -> usize

Source§

unsafe fn get_value_unchecked(&self, index: usize) -> B::Word

Source§

fn is_empty(&self) -> bool

Source§

fn index_value(&self, index: usize) -> Self::Value

Source§

fn get_value(&self, index: usize) -> Option<Self::Value>

Source§

impl<V: Word, D: TryIntoUnaligned + SliceByValue<Value = u64>> TryIntoUnaligned for CompIntList<BitVec<Box<[V]>>, D>
where D::Unaligned: SliceByValue<Value = u64>,

Source§

fn try_into_unaligned(self) -> Result<Self::Unaligned, UnalignedConversionError>

This method will fail if any stored value has a bit width that does not satisfy the constraints for unaligned reads.

Source§

type Unaligned = CompIntList<BitVecU<Box<[V]>>, <D as TryIntoUnaligned>::Unaligned>

The unaligned version of this type.
Source§

impl<B, D> TypeHash for CompIntList<B, D>
where usize: SerInner<SerType: TypeHash>, B::Word: SerInner<SerType: TypeHash>, D: SerInner<SerType: TypeHash>, B: SerInner<SerType: TypeHash> + Backend, bool: SerInner<SerType: TypeHash>,

Source§

fn type_hash(hasher: &mut impl Hasher)

Accumulates type information in hasher.
Source§

fn type_hash_val(&self, hasher: &mut impl Hasher)

Calls TypeHash::type_hash on a value.

Auto Trait Implementations§

§

impl<B, D> Freeze for CompIntList<B, D>
where <B as Backend>::Word: Freeze, D: Freeze, B: Freeze,

§

impl<B, D> RefUnwindSafe for CompIntList<B, D>

§

impl<B, D> Send for CompIntList<B, D>
where <B as Backend>::Word: Send, D: Send, B: Send,

§

impl<B, D> Sync for CompIntList<B, D>
where <B as Backend>::Word: Sync, D: Sync, B: Sync,

§

impl<B, D> Unpin for CompIntList<B, D>
where <B as Backend>::Word: Unpin, D: Unpin, B: Unpin,

§

impl<B, D> UnsafeUnpin for CompIntList<B, D>

§

impl<B, D> UnwindSafe for CompIntList<B, D>
where <B as Backend>::Word: UnwindSafe, D: UnwindSafe, B: 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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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

Available on crate feature std only.
Writes to stderr debug info 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>

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

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

Available on crate feature std only.
Writes to stderr debug info about the structure memory usage as mem_dbg, but expanding only up to max_depth levels of nested structures.
Source§

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,