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
impl RankSupport
Sourcepub const BLOCK_SIZE: usize = 512usize
pub const BLOCK_SIZE: usize = 512usize
Number of bits per block (512).
Sourcepub fn new(parent: &BitVector) -> RankSupport
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);Sourcepub fn rank(&self, parent: &BitVector, index: usize) -> usize
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().
Sourcepub unsafe fn rank_unchecked(&self, parent: &BitVector, index: usize) -> usize
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
impl Clone for RankSupport
Source§fn clone(&self) -> RankSupport
fn clone(&self) -> RankSupport
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RankSupport
impl Debug for RankSupport
Source§impl PartialEq for RankSupport
impl PartialEq for RankSupport
Source§impl Serialize for RankSupport
impl Serialize for RankSupport
Source§fn serialize_header<T: Write>(&self, writer: &mut T) -> Result<()>
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<()>
fn serialize_body<T: Write>(&self, writer: &mut T) -> Result<()>
Serializes the body to the writer. Read more
Source§fn size_in_elements(&self) -> usize
fn size_in_elements(&self) -> usize
Source§fn serialize<T: Write>(&self, writer: &mut T) -> Result<()>
fn serialize<T: Write>(&self, writer: &mut T) -> Result<()>
Serializes the struct to the writer. Read more
Source§fn size_in_bytes(&self) -> usize
fn size_in_bytes(&self) -> usize
Returns the size of the serialized struct in bytes. Read more
impl Eq for RankSupport
impl StructuralPartialEq for RankSupport
Auto Trait Implementations§
impl Freeze for RankSupport
impl RefUnwindSafe for RankSupport
impl Send for RankSupport
impl Sync for RankSupport
impl Unpin for RankSupport
impl UnwindSafe for RankSupport
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
Mutably borrows from an owned value. Read more