RankSupport

Struct RankSupport 

Source
pub struct RankSupport { /* private fields */ }
Expand description

Rank 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.

Implementations§

Source§

impl RankSupport

Source

pub const BLOCK_SIZE: usize = 512usize

Number of bits per block (512).

Source

pub fn blocks(&self) -> usize

Returns the number of 512-bit blocks in the bitvector.

Source

pub fn new(parent: &BitVector) -> RankSupport

Builds a rank support structure for the parent bitvector.

§Examples
use simple_sds_sbwt::bit_vector::BitVector;
use simple_sds_sbwt::bit_vector::rank_support::RankSupport;

let data = vec![false, true, true, false, true, false, true, true, false, false, false];
let bv: BitVector = data.into_iter().collect();
let rs = RankSupport::new(&bv);
assert_eq!(rs.blocks(), 1);
Source

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

Returns the rank at the specified index of the bitvector.

§Arguments
  • parent: The parent bitvector.
  • index: Index in the bit array or value in the integer array.
§Examples
use simple_sds_sbwt::bit_vector::BitVector;
use simple_sds_sbwt::bit_vector::rank_support::RankSupport;

let data = vec![false, true, true, false, true, false, true, true, false, false, false];
let bv: BitVector = data.into_iter().collect();
let rs = RankSupport::new(&bv);
assert_eq!(rs.rank(&bv, 0), 0);
assert_eq!(rs.rank(&bv, 1), 0);
assert_eq!(rs.rank(&bv, 2), 1);
assert_eq!(rs.rank(&bv, 7), 4);
§Panics

May panic if index >= parent.len().

Source

pub unsafe fn rank_unchecked(&self, parent: &BitVector, index: usize) -> usize

Unsafe version of RankSupport::rank without bounds checks.

§Safety

Behavior is undefined if index >= parent.len().

Trait Implementations§

Source§

impl Clone for RankSupport

Source§

fn clone(&self) -> RankSupport

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 Debug for RankSupport

Source§

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

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

impl PartialEq for RankSupport

Source§

fn eq(&self, other: &RankSupport) -> 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 Serialize for RankSupport

Source§

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

Serializes the header to the writer. Read more
Source§

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

Serializes the body to the writer. Read more
Source§

fn load<T: Read>(reader: &mut T) -> 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 Eq for RankSupport

Source§

impl StructuralPartialEq for RankSupport

Auto Trait Implementations§

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.