SelectSupport

Struct SelectSupport 

Source
pub struct SelectSupport<T: Transformation> { /* private fields */ }
Expand description

Select support structure for plain bitvectors.

The structure depends on the parent bitvector and assumes that the parent remains unchanged. Using the BitVector interface is usually more convenient.

This type must be parametrized with a Transformation.

Implementations§

Source§

impl<T: Transformation> SelectSupport<T>

Source

pub const SUPERBLOCK_SIZE: usize = 4_096usize

Number of ones per superblock (4096).

Source

pub fn superblocks(&self) -> usize

Returns the number superblocks in the bitvector.

Source

pub fn long_superblocks(&self) -> usize

Returns the number of long superblocks in the bitvector.

Source

pub fn short_superblocks(&self) -> usize

Returns the number of short superblocks in the bitvector.

Source

pub fn new(parent: &BitVector) -> SelectSupport<T>

Builds a select support structure for the parent bitvector.

§Examples
use simple_sds_sbwt::bit_vector::{BitVector, Identity};
use simple_sds_sbwt::bit_vector::select_support::SelectSupport;

let mut data = vec![false, true, true, false, true, false, true, true, false, false, false];
let bv: BitVector = data.into_iter().collect();
let ss = SelectSupport::<Identity>::new(&bv);
assert_eq!(ss.superblocks(), 1);
assert_eq!(ss.long_superblocks(), 0);
assert_eq!(ss.short_superblocks(), 1);
Source

pub fn select(&self, parent: &BitVector, rank: usize) -> usize

Returns the value of the specified rank in the parent bitvector.

§Arguments
  • parent: The parent bitvector.
  • rank: Index in the integer array or rank of a set bit in the bit array.
§Examples
use simple_sds_sbwt::bit_vector::{BitVector, Identity};
use simple_sds_sbwt::bit_vector::select_support::SelectSupport;

let mut data = vec![false, true, true, false, true, false, true, true, false, false, false];
let bv: BitVector = data.into_iter().collect();
let ss = SelectSupport::<Identity>::new(&bv);
assert_eq!(ss.select(&bv, 0), 1);
assert_eq!(ss.select(&bv, 1), 2);
assert_eq!(ss.select(&bv, 4), 7);
§Panics

May panic if rank >= T::count_ones(parent).

Source

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

Unsafe version of SelectSupport::select without some bounds checks.

§Safety

Behavior is undefined if rank >= T::count_ones(parent).

Trait Implementations§

Source§

impl<T: Clone + Transformation> Clone for SelectSupport<T>

Source§

fn clone(&self) -> SelectSupport<T>

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<T: Debug + Transformation> Debug for SelectSupport<T>

Source§

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

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

impl<T: PartialEq + Transformation> PartialEq for SelectSupport<T>

Source§

fn eq(&self, other: &SelectSupport<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Transformation> Serialize for SelectSupport<T>

Source§

fn serialize_header<W: Write>(&self, _: &mut W) -> Result<()>

Serializes the header to the writer. Read more
Source§

fn serialize_body<W: Write>(&self, writer: &mut W) -> Result<()>

Serializes the body to the writer. Read more
Source§

fn load<W: Read>(reader: &mut W) -> Result<Self>

Loads the struct from the reader. Read more
Source§

fn size_in_elements(&self) -> usize

Returns the size of the serialized struct in u64 elements. Read more
Source§

fn serialize<T: Write>(&self, writer: &mut T) -> Result<()>

Serializes the struct to the writer. Read more
Source§

fn size_in_bytes(&self) -> usize

Returns the size of the serialized struct in bytes. Read more
Source§

impl<T: Eq + Transformation> Eq for SelectSupport<T>

Source§

impl<T: Transformation> StructuralPartialEq for SelectSupport<T>

Auto Trait Implementations§

§

impl<T> Freeze for SelectSupport<T>

§

impl<T> RefUnwindSafe for SelectSupport<T>
where T: RefUnwindSafe,

§

impl<T> Send for SelectSupport<T>
where T: Send,

§

impl<T> Sync for SelectSupport<T>
where T: Sync,

§

impl<T> Unpin for SelectSupport<T>
where T: Unpin,

§

impl<T> UnwindSafe for SelectSupport<T>
where T: 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> 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.