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>
impl<T: Transformation> SelectSupport<T>
Sourcepub const SUPERBLOCK_SIZE: usize = 4_096usize
pub const SUPERBLOCK_SIZE: usize = 4_096usize
Number of ones per superblock (4096).
Sourcepub fn superblocks(&self) -> usize
pub fn superblocks(&self) -> usize
Returns the number superblocks in the bitvector.
Sourcepub fn long_superblocks(&self) -> usize
pub fn long_superblocks(&self) -> usize
Returns the number of long superblocks in the bitvector.
Sourcepub fn short_superblocks(&self) -> usize
pub fn short_superblocks(&self) -> usize
Returns the number of short superblocks in the bitvector.
Sourcepub fn new(parent: &BitVector) -> SelectSupport<T>
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);Sourcepub fn select(&self, parent: &BitVector, rank: usize) -> usize
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).
Sourcepub unsafe fn select_unchecked(&self, parent: &BitVector, rank: usize) -> usize
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>
impl<T: Clone + Transformation> Clone for SelectSupport<T>
Source§fn clone(&self) -> SelectSupport<T>
fn clone(&self) -> SelectSupport<T>
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<T: Debug + Transformation> Debug for SelectSupport<T>
impl<T: Debug + Transformation> Debug for SelectSupport<T>
Source§impl<T: PartialEq + Transformation> PartialEq for SelectSupport<T>
impl<T: PartialEq + Transformation> PartialEq for SelectSupport<T>
Source§impl<T: Transformation> Serialize for SelectSupport<T>
impl<T: Transformation> Serialize for SelectSupport<T>
Source§fn serialize_header<W: Write>(&self, _: &mut W) -> Result<()>
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<()>
fn serialize_body<W: Write>(&self, writer: &mut W) -> 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<T: Eq + Transformation> Eq for SelectSupport<T>
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> 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