Struct SelectSupportMcl

Source
pub struct SelectSupportMcl<'a, BitPattern: BitPattern> { /* private fields */ }
Expand description

A class supporting constant time select queries.

§Space usage

The space usage of the data structure depends on the number of $m$ of ones in the original bitvector $b$. We store the position of every 4096-th set bit (called L1-sampled bits) of $b$. This takes in the worst case $ \frac{m}{4096} \log{n} \leq \frac{n}{64} $ bits.

Next, (1) if the distance of two adjacent L1-sampled bits $b[i]$ and $b[j]$ is greater or equal than $\log^4 n$, then we store each of the 4096 positions of the set $b$ in [i..j-1] with $\log{n}$ bits. This results in at most $ \frac{4096\cdot \log n}{\log^4 n}=\frac{4096}{\log^3 n}$ bits per bit. For a bitvector of 4GB, i.e. $ \log n = 35 $ we get about 0.01 bits per bit. If the $j-i+1 < \log^4 n$ then (2) we store the relative position of every $64$th set bit (called L2-sampled bits) in b[i..j-1] in at most $4\log\log n$ bits per L2-sampled bits. An pessimistic upper bound for the space would be $ \frac{4\log\log n}{64} \leq \frac{24}{64} = 0.375 $ bit per bit (since $\log\log n\leq 6$. It is very pessimistic, since we store the relative position in $\log\log(j-i+1)\leq \log\log n$ bits.

§Arguments

  • BitPattern - Bit pattern 0,1,10,01 supported by select query.

§Example

let bv = sdsl::bit_vector! {0, 1, 0, 1, 0, 0, 0};
let ss = sdsl::select_supports::SelectSupportMcl::<sdsl::BitPatterns::P1>::new(&bv)?;
let result = ss.select(2);
let expected = 3;
assert_eq!(result, expected);

For further examples see here.

§References

Implementations§

Source§

impl<'a, BitPattern: BitPattern> SelectSupportMcl<'a, BitPattern>

Source

pub fn new(bit_vector: &'a BitVector) -> Result<Self>

Construct a new select support structure.

§Arguments
  • bit_vector - Bit vector.
Source

pub fn from_file(path: &PathBuf) -> Result<Self>

Load from file.

§Arguments
  • path - File path.
Source

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

Returns the position of the i-th bit pattern instance in the bit vector.

§Arguments
  • index - An index within the range of the supported bit vector.

Trait Implementations§

Source§

impl<'a, BitPattern: BitPattern> Drop for SelectSupportMcl<'a, BitPattern>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, BitPattern> Freeze for SelectSupportMcl<'a, BitPattern>
where BitPattern: Freeze,

§

impl<'a, BitPattern> RefUnwindSafe for SelectSupportMcl<'a, BitPattern>
where BitPattern: RefUnwindSafe,

§

impl<'a, BitPattern> !Send for SelectSupportMcl<'a, BitPattern>

§

impl<'a, BitPattern> !Sync for SelectSupportMcl<'a, BitPattern>

§

impl<'a, BitPattern> Unpin for SelectSupportMcl<'a, BitPattern>
where BitPattern: Unpin,

§

impl<'a, BitPattern> UnwindSafe for SelectSupportMcl<'a, BitPattern>
where BitPattern: 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.