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 x − min + 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 implementBackendandBitVecValueOps<B::Word>. Defaults to [BitVec<Box<[usize]>>].D: The delimiter structure. Must implementSliceByValue<Value = u64>. Defaults toEfSeq<u64>.
Implementations§
Source§impl<V: Word> CompIntList<BitVec<Box<[V]>>>
impl<V: Word> CompIntList<BitVec<Box<[V]>>>
Sourcepub fn new<I: ?Sized>(min: V, values: &I) -> Self
pub fn new<I: ?Sized>(min: V, values: &I) -> Self
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>
impl<B: Backend<Word: Word> + BitVecValueOps<B::Word>, D: SliceByValue<Value = u64>> CompIntList<B, D>
Sourcepub unsafe fn map_delimiters<F, D2>(self, func: F) -> CompIntList<B, D2>
pub unsafe fn map_delimiters<F, D2>(self, func: F) -> CompIntList<B, D2>
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.
Sourcepub unsafe fn map_data<F, B2>(self, func: F) -> CompIntList<B2, D>
pub unsafe fn map_data<F, B2>(self, func: F) -> CompIntList<B2, D>
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.
Sourcepub fn into_inner(self) -> D
pub fn into_inner(self) -> D
Returns the underlying delimiter structure.
Trait Implementations§
Source§impl<B, D> AlignHash for CompIntList<B, D>
impl<B, D> AlignHash for CompIntList<B, D>
Source§fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
hasher assuming to be positioned
at offset_of.Source§fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
AlignHash::align_hash on a value.Source§impl<B: Clone + Backend, D: Clone> Clone for CompIntList<B, D>
impl<B: Clone + Backend, D: Clone> Clone for CompIntList<B, D>
Source§fn clone(&self) -> CompIntList<B, D>
fn clone(&self) -> CompIntList<B, D>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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,
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>>
type DeserType<'__epserde_desertype> = CompIntList<<B as DeserInner>::DeserType<'__epserde_desertype>, <D as DeserInner>::DeserType<'__epserde_desertype>>
DeserType.Source§fn __check_covariance<'__long: '__short, '__short>(
proof: CovariantProof<Self::DeserType<'__long>>,
) -> CovariantProof<Self::DeserType<'__short>>
fn __check_covariance<'__long: '__short, '__short>( proof: CovariantProof<Self::DeserType<'__long>>, ) -> CovariantProof<Self::DeserType<'__short>>
Source§unsafe fn _deser_full_inner(
backend: &mut impl ReadWithPos,
) -> Result<Self, Error>
unsafe fn _deser_full_inner( backend: &mut impl ReadWithPos, ) -> Result<Self, Error>
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>
unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>( backend: &mut SliceWithPos<'deser_eps_inner_lifetime>, ) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>
Source§impl<'de, B, D> Deserialize<'de> for CompIntList<B, D>
impl<'de, B, D> Deserialize<'de> for CompIntList<B, D>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<B, D> FlatType for CompIntList<B, D>
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>,
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§impl<B, D> MemDbgImpl for CompIntList<B, D>where
usize: MemDbgImpl + FlatType,
B::Word: MemDbgImpl + FlatType,
D: MemDbgImpl + FlatType,
B: MemDbgImpl + FlatType + Backend,
bool: MemDbgImpl + FlatType,
impl<B, D> MemDbgImpl for CompIntList<B, D>where
usize: MemDbgImpl + FlatType,
B::Word: MemDbgImpl + FlatType,
D: MemDbgImpl + FlatType,
B: MemDbgImpl + FlatType + Backend,
bool: MemDbgImpl + FlatType,
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
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>
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>
Source§impl<B, D> MemSize for CompIntList<B, D>
impl<B, D> MemSize for CompIntList<B, D>
Source§impl<B, D> SerInner for CompIntList<B, D>
impl<B, D> SerInner for CompIntList<B, D>
Source§const IS_ZERO_COPY: bool
const IS_ZERO_COPY: bool
ZeroCopy type has this constant set to false
serialization will panic.Source§type SerType = CompIntList<<B as SerInner>::SerType, <D as SerInner>::SerType>
type SerType = CompIntList<<B as SerInner>::SerType, <D as SerInner>::SerType>
Self, but
in some cases, as for references to slices,
it is customized.Source§unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
Source§impl<B, D> Serialize for CompIntList<B, D>
impl<B, D> Serialize for CompIntList<B, D>
Source§impl<B: Backend<Word: Word> + BitVecValueOps<B::Word>, D: SliceByValue<Value = u64>> SliceByValue for CompIntList<B, D>where
for<'a> &'a D: IntoIteratorFrom,
for<'a> <&'a D as IntoIteratorFrom>::IntoIterFrom: UncheckedIterator<Item = u64>,
impl<B: Backend<Word: Word> + BitVecValueOps<B::Word>, D: SliceByValue<Value = u64>> SliceByValue for CompIntList<B, D>where
for<'a> &'a D: IntoIteratorFrom,
for<'a> <&'a D as IntoIteratorFrom>::IntoIterFrom: UncheckedIterator<Item = u64>,
Source§fn len(&self) -> usize
fn len(&self) -> usize
slice::len.Source§unsafe fn get_value_unchecked(&self, index: usize) -> B::Word
unsafe fn get_value_unchecked(&self, index: usize) -> B::Word
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
slice::is_empty.Source§fn index_value(&self, index: usize) -> Self::Value
fn index_value(&self, index: usize) -> Self::Value
Source§impl<V: Word, D: TryIntoUnaligned + SliceByValue<Value = u64>> TryIntoUnaligned for CompIntList<BitVec<Box<[V]>>, D>
impl<V: Word, D: TryIntoUnaligned + SliceByValue<Value = u64>> TryIntoUnaligned for CompIntList<BitVec<Box<[V]>>, D>
Source§fn try_into_unaligned(self) -> Result<Self::Unaligned, UnalignedConversionError>
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>
type Unaligned = CompIntList<BitVecU<Box<[V]>>, <D as TryIntoUnaligned>::Unaligned>
Source§impl<B, D> TypeHash for CompIntList<B, D>
impl<B, D> TypeHash for CompIntList<B, D>
Source§fn type_hash_val(&self, hasher: &mut impl Hasher)
fn type_hash_val(&self, hasher: &mut impl Hasher)
TypeHash::type_hash on a value.Auto Trait Implementations§
impl<B, D> Freeze for CompIntList<B, D>
impl<B, D> RefUnwindSafe for CompIntList<B, D>
impl<B, D> Send for CompIntList<B, D>
impl<B, D> Sync for CompIntList<B, D>
impl<B, D> Unpin for CompIntList<B, D>
impl<B, D> UnsafeUnpin for CompIntList<B, D>
impl<B, D> UnwindSafe for CompIntList<B, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
std only.Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
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>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
std only.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>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
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.