Struct sux::rank_sel::SelectFixed1

source ·
pub struct SelectFixed1<B: SelectHinted = CountBitVec, O: BitFieldSlice<usize> = Vec<usize>, const LOG2_ONES_PER_INVENTORY: usize = 8> { /* private fields */ }
Expand description

A selection structure based on a one-level index.

More precisely, given a constant LOG2_ONES_PER_INVENTORY, this index records the position of one every 2LOG2_ONES_PER_INVENTORY. The positions are recorded in a BitFieldSlice whose bit width must be sufficient to record all the positions.

Note that SelectFixed2 has usually better performance than this structure, which is mainly useful for testing, benchmarking and debugging.

The current implementation uses a Vec<usize> as the underlying BitFieldSlice. Thus, the overhead of the structure is BitCount::count() * usize::BITS / 2LOG2_ONES_PER_INVENTORY bits.

The index takes a backend parameter B that can be any type that implements SelectHinted. This will usually be something like CountBitVec, or possibly a CountBitVec wrapped in another index structure for which this structure has delegation (e.g., SelectZeroFixed1). See the documentation of EliasFano for an example of this approach.

See SelectZeroFixed1 for the same structure for zeros.

Implementations§

source§

impl<B: SelectHinted + AsRef<[usize]>, const LOG2_ONES_PER_INVENTORY: usize> SelectFixed1<B, Vec<usize>, LOG2_ONES_PER_INVENTORY>

source

pub fn new(bitvec: B, number_of_ones: usize) -> Self

Trait Implementations§

source§

impl<B: SelectHinted + AsRef<[usize]>, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> AsRef<[usize]> for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward AsRef<[usize]> to the underlying implementation.

source§

fn as_ref(&self) -> &[usize]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<B: SelectHinted + BitCount, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> BitCount for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward BitCount to the underlying implementation.

source§

fn count(&self) -> usize

Return the number of ones in the underlying bit vector.
source§

impl<B: SelectHinted + BitLength, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> BitLength for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward BitLength to the underlying implementation.

source§

fn len(&self) -> usize

Return the length in bits of the underlying bit vector.
source§

impl<B: Clone + SelectHinted, O: Clone + BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> Clone for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

source§

fn clone(&self) -> SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

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<B: SelectHinted, T, const LOG2_ONES_PER_INVENTORY: usize> ConvertTo<B> for SelectFixed1<B, T, LOG2_ONES_PER_INVENTORY>
where T: AsRef<[usize]>,

Forget the index.

source§

fn convert_to(self) -> Result<B>

source§

impl<B: SelectHinted, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> CopyType for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

§

type Copy = Deep

source§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> CopyType for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

§

type Copy = False

source§

impl<B: Debug + SelectHinted, O: Debug + BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> Debug for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

source§

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

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

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> DeserializeInner for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: DeserializeInner + SelectHinted, O: DeserializeInner + BitFieldSlice<usize>, PhantomData<[(); LOG2_ONES_PER_INVENTORY]>: DeserializeInner, for<'epserde_desertype> <B as DeserializeInner>::DeserType<'epserde_desertype>: SelectHinted, for<'epserde_desertype> <O as DeserializeInner>::DeserType<'epserde_desertype>: BitFieldSlice<usize>,

source§

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

§

type DeserType<'epserde_desertype> = SelectFixed1<<B as DeserializeInner>::DeserType<'epserde_desertype>, <O as DeserializeInner>::DeserType<'epserde_desertype>, LOG2_ONES_PER_INVENTORY>

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

fn _deserialize_eps_inner<'a>( backend: &mut SliceWithPos<'a> ) -> Result<Self::DeserType<'a>, Error>

source§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> MemDbgImpl for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

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<B, O, const LOG2_ONES_PER_INVENTORY: usize> MemSize for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

source§

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

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

impl<B: SelectHinted + Rank, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> Rank for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward Rank to the underlying implementation.

source§

fn rank(&self, pos: usize) -> usize

Return the number of ones preceding the specified position.
source§

unsafe fn rank_unchecked(&self, pos: usize) -> usize

Return the number of ones preceding the specified position. Read more
source§

impl<B: SelectHinted + RankZero, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> RankZero for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward RankZero to the underlying implementation.

source§

fn rank_zero(&self, pos: usize) -> usize

Return the number of zeros preceding the specified position.
source§

unsafe fn rank_zero_unchecked(&self, pos: usize) -> usize

Return the number of zeros preceding the specified position. Read more
source§

impl<B: SelectHinted + ReprHash, O: BitFieldSlice<usize> + ReprHash, const LOG2_ONES_PER_INVENTORY: usize> ReprHash for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

source§

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

Accumulate representional information in hasher assuming to be positioned at offset_of.
source§

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

Call ReprHash::repr_hash on a value.
source§

impl<B: SelectHinted + BitCount, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> Select for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Provide the hint to the underlying structure

source§

unsafe fn select_unchecked(&self, rank: usize) -> usize

Return the position of the one of given rank. Read more
source§

fn select(&self, rank: usize) -> Option<usize>

Return the position of the one of given rank, or None if no such bit exist.
source§

impl<B: SelectHinted + SelectZero, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> SelectZero for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward SelectZero to the underlying implementation.

source§

fn select_zero(&self, rank: usize) -> Option<usize>

Return the position of the zero of given rank, or None if no such bit exist.
source§

unsafe fn select_zero_unchecked(&self, rank: usize) -> usize

Return the position of the zero of given rank. Read more
source§

impl<B: SelectHinted + SelectZeroHinted, O: BitFieldSlice<usize>, const LOG2_ONES_PER_INVENTORY: usize> SelectZeroHinted for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

Forward SelectZeroHinted to the underlying implementation.

source§

unsafe fn select_zero_hinted_unchecked( &self, rank: usize, pos: usize, rank_at_pos: usize ) -> usize

Select the zero of given rank, provided the position of a preceding zero and its rank. Read more
source§

fn select_zero_hinted( &self, rank: usize, pos: usize, rank_at_pos: usize ) -> Option<usize>

Select the zero of given rank, provided the position of a preceding zero and its rank.
source§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> SerializeInner for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

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§

const ZERO_COPY_MISMATCH: bool = _

Inner constant used by the derive macros to keep track of whether all fields of a type are zero-copy but neither the attribute #[zero_copy] nor the attribute #[deep_copy] was specified. It is checked at runtime, and if it is true a warning will be issued, as the type could be zero-copy, which would be more efficient.
source§

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

Serialize this structure using the given backend.
source§

impl<B: SelectHinted + TypeHash, O: BitFieldSlice<usize> + TypeHash, const LOG2_ONES_PER_INVENTORY: usize> TypeHash for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

source§

fn type_hash(hasher: &mut impl Hasher)

Accumulate type information in hasher.
source§

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

Call TypeHash::type_hash on a value.

Auto Trait Implementations§

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> Freeze for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: Freeze, O: Freeze,

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> RefUnwindSafe for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> Send for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: Send, O: Send,

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> Sync for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: Sync, O: Sync,

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> Unpin for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: Unpin, O: Unpin,

§

impl<B, O, const LOG2_ONES_PER_INVENTORY: usize> UnwindSafe for SelectFixed1<B, O, LOG2_ONES_PER_INVENTORY>
where B: UnwindSafe, O: 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> BitFieldSlice<usize> for T
where T: AsRef<[usize]>,

source§

unsafe fn get_unchecked(&self, index: usize) -> usize

Return the value at the specified index. Read more
source§

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

Return the value at the specified index. Read more
source§

impl<T> BitFieldSliceCore<usize> for T
where T: AsRef<[usize]>,

source§

fn bit_width(&self) -> usize

Return the width of the slice. All elements stored in the slice must fit within this bit width.
source§

fn len(&self) -> usize

Return the length of the slice.
source§

fn is_empty(&self) -> bool

Return if the slice has length zero
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<B, const LOG2_ONES_PER_INVENTORY: usize> ConvertTo<SelectFixed1<B, Vec<usize>, LOG2_ONES_PER_INVENTORY>> for B
where B: SelectHinted + BitCount + AsRef<[usize]>,

source§

fn convert_to( self ) -> Result<SelectFixed1<B, Vec<usize>, LOG2_ONES_PER_INVENTORY>, Error>

source§

impl<B, const LOG2_ZEROS_PER_INVENTORY: usize> ConvertTo<SelectZeroFixed1<B, Vec<usize>, LOG2_ZEROS_PER_INVENTORY>> for B

source§

fn convert_to( self ) -> Result<SelectZeroFixed1<B, Vec<usize>, LOG2_ZEROS_PER_INVENTORY>, Error>

source§

impl<B, const LOG2_ZEROS_PER_INVENTORY: usize, const LOG2_U64_PER_SUBINVENTORY: usize> ConvertTo<SelectZeroFixed2<B, Vec<u64>, LOG2_ZEROS_PER_INVENTORY, LOG2_U64_PER_SUBINVENTORY>> for B

source§

fn convert_to( self ) -> Result<SelectZeroFixed2<B, Vec<u64>, LOG2_ZEROS_PER_INVENTORY, LOG2_U64_PER_SUBINVENTORY>, Error>

source§

impl<T> Deserialize for T

source§

fn deserialize_full(backend: &mut impl ReadNoStd) -> Result<T, Error>

Fully deserialize a structure of this type from the given backend.
source§

fn deserialize_eps( backend: &[u8] ) -> Result<<T as DeserializeInner>::DeserType<'_>, Error>

ε-copy deserialize a structure of this type from the given backend.
source§

fn load_full(path: impl AsRef<Path>) -> Result<Self, Error>

Commodity method to fully deserialize from a file.
source§

fn load_mem<'a>( path: impl AsRef<Path> ) -> Result<MemCase<Self::DeserType<'a>>, Error>

Load a file into heap-allocated memory and ε-deserialize a data structure from it, returning a MemCase containing the data structure and the memory. Excess bytes are zeroed out. Read more
source§

fn load_mmap<'a>( path: impl AsRef<Path>, flags: Flags ) -> Result<MemCase<Self::DeserType<'a>>, Error>

Load a file into mmap()-allocated memory and ε-deserialize a data structure from it, returning a MemCase containing the data structure and the memory. Excess bytes are zeroed out. Read more
source§

fn mmap<'a>( path: impl AsRef<Path>, flags: Flags ) -> Result<MemCase<Self::DeserType<'a>>, Error>

Memory map a file and ε-deserialize a data structure from it, returning a MemCase containing the data structure and the memory mapping. 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

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> Serialize for T

source§

fn serialize_on_field_write( &self, backend: &mut impl WriteWithNames ) -> Result<(), Error>

Serialize the type using the given WriteWithNames.

source§

fn serialize(&self, backend: &mut impl WriteNoStd) -> Result<usize, Error>

Serialize the type using the given backend.
source§

fn serialize_with_schema( &self, backend: &mut impl WriteNoStd ) -> Result<Schema, Error>

Serialize the type using the given backend and return a schema describing the data that has been written. Read more
source§

fn store(&self, path: impl AsRef<Path>) -> Result<(), Error>

Commodity method to serialize to a file.
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,

§

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>,

§

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>,

§

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<T> DeepCopy for T
where T: CopyType<Copy = Deep>,