pub struct RSQVector<S> { /* private fields */ }
Expand description

The generic S is the data structure used to provide rank/select support at the level of blocks.

Implementations§

source§

impl<S> RSQVector<S>

source

pub fn iter(&self) -> QVectorIterator<&QVector>

Returns an iterator over the values in the quad vector.

Examples
use qwt::RSQVector256;

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

for (i, v) in rsqv.iter().enumerate() {
   assert_eq!((i%4) as u8, v);
}
source§

impl<S: RSSupport> RSQVector<S>

source

pub fn new<T>(v: &[T]) -> Self

Creates a quad vector with support for RankQuad and SelectQuad queries for a sequence of integers in the range [0, 3].

Panics

Panics if the vector is longer than the largest possible length 2^{43}-1 symbols. If you need longer vectors, consider using a vector of RSQVectors, each of length smaller than 2^{43} symbols. This limit is due to two different reasons: - The number of occurrences of a symbol up to the beginning of its superblock is stored in 44 bits. - A select sample stores a superblock id. The size of a superblock is at least 2048 symbols, thus a superblock id for a sequence of length 2^{43}-1 fits in 32 bits.

Examples
use qwt::RSQVector256;

let v: Vec<u64> = (0..10).into_iter().map(|x| x % 4).collect();
let rsqv = RSQVector256::new(&v);

assert_eq!(rsqv.is_empty(), false);
assert_eq!(rsqv.len(), 10);
source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

Checks if the vector is empty.

Trait Implementations§

source§

impl<S> AccessQuad for RSQVector<S>

source§

unsafe fn get_unchecked(&self, i: usize) -> u8

Accesses the i-th value in the quad vector. The caller must guarantee that the position i is valid.

Safety

Calling this method with an out-of-bounds index is undefined behavior.

Examples
use qwt::{RSQVector256, AccessQuad};

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

assert_eq!(unsafe { rsqv.get_unchecked(0) }, 0);
assert_eq!(unsafe { rsqv.get_unchecked(1) }, 1);
source§

fn get(&self, i: usize) -> Option<u8>

Accesses the ith value in the quad vector or None if out of bounds.

Examples
use qwt::{RSQVector256, AccessQuad};

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

assert_eq!(rsqv.get(0), Some(0));
assert_eq!(rsqv.get(1), Some(1));
assert_eq!(rsqv.get(10), None);
source§

impl<S> AsRef<RSQVector<S>> for RSQVector<S>

source§

fn as_ref(&self) -> &RSQVector<S>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S: Clone> Clone for RSQVector<S>

source§

fn clone(&self) -> RSQVector<S>

Returns a copy 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<S: Debug> Debug for RSQVector<S>

source§

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

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

impl<S: Default> Default for RSQVector<S>

source§

fn default() -> RSQVector<S>

Returns the “default value” for a type. Read more
source§

impl<'de, S> Deserialize<'de> for RSQVector<S>
where S: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<S: RSSupport> From<QVector> for RSQVector<S>

source§

fn from(qv: QVector) -> Self

Converts a given quad vector qv into a RSQVector with support for rank and select queries.

Examples
use qwt::RSQVector256;

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

assert_eq!(rsqv.is_empty(), false);
assert_eq!(rsqv.len(), 10);
source§

impl<T, S: RSSupport> FromIterator<T> for RSQVector<S>
where T: PrimInt + AsPrimitive<u8>,

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<'a, S> IntoIterator for &'a RSQVector<S>

§

type IntoIter = QVectorIterator<&'a QVector>

Which kind of iterator are we turning this into?
§

type Item = u8

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<S> IntoIterator for RSQVector<S>

§

type IntoIter = QVectorIterator<QVector>

Which kind of iterator are we turning this into?
§

type Item = u8

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<S: PartialEq> PartialEq for RSQVector<S>

source§

fn eq(&self, other: &RSQVector<S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<S: RSSupport> RankQuad for RSQVector<S>

source§

fn rank(&self, symbol: u8, i: usize) -> Option<usize>

Returns rank of symbol up to position i excluded. Returns None if out of bounds.

Examples
use qwt::{RSQVector256, RankQuad};

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

assert_eq!(rsqv.rank(0, 0), Some(0));
assert_eq!(rsqv.rank(0, 1), Some(1));
assert_eq!(rsqv.rank(0, 2), Some(1));
assert_eq!(rsqv.rank(0, 10), Some(3));
assert_eq!(rsqv.rank(0, 11), None);
source§

unsafe fn rank_unchecked(&self, symbol: u8, i: usize) -> usize

Returns rank of symbol up to position i excluded.

Safety

Calling this method with a position i larger than the length of the vector is undefined behavior.

source§

impl<S: RSSupport> SelectQuad for RSQVector<S>

source§

fn select(&self, symbol: u8, i: usize) -> Option<usize>

Returns the position of the ith occurrence of symbol. Returns None if i is not valid, i.e., if i == 0 or i is larger than the number of occurrences of symbol, or if symbol is not in [0..3].

Examples
use qwt::{RSQVector256, SelectQuad};

let rsqv: RSQVector256 = (0..10_u64).into_iter().map(|x| x % 4).collect();

assert_eq!(rsqv.select(0, 1), Some(0));
assert_eq!(rsqv.select(0, 2), Some(4));
assert_eq!(rsqv.select(0, 3), Some(8));
assert_eq!(rsqv.select(0, 0), None);
assert_eq!(rsqv.select(0, 4), None);
source§

unsafe fn select_unchecked(&self, symbol: u8, i: usize) -> usize

Returns the position of the ith occurrence of symbol.

Safety

Calling this method with a value of i which is larger than the number of occurrences of the symbol or if `symbol is larger than 3 is
undefined behavior.

In the current implementation there is no reason to prefer this unsafe select over the safe one.

source§

impl<S> Serialize for RSQVector<S>
where S: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<S: SpaceUsage> SpaceUsage for RSQVector<S>

source§

fn space_usage_byte(&self) -> usize

Gives the space usage in bytes of the data structure.

source§

fn space_usage_KiB(&self) -> f64

Gives the space usage of the data structure in KiB.
source§

fn space_usage_MiB(&self) -> f64

Gives the space usage of the data structure in MiB.
source§

fn space_usage_GiB(&self) -> f64

Gives the space usage of the data structure in GiB.
source§

impl<S: RSSupport> WTSupport for RSQVector<S>

source§

fn occs(&self, symbol: u8) -> Option<usize>

Returns the number of occurrences of symbol in the indexed sequence, None if symbol is not in [0..3].

source§

unsafe fn occs_unchecked(&self, symbol: u8) -> usize

Returns the number of occurrences of symbol in the indexed sequence.

Safety

Calling this method if the symbol is not in [0..3] is undefined behavior.

source§

fn occs_smaller(&self, symbol: u8) -> Option<usize>

Returns the number of occurrences of all the symbols smaller than the input symbol, None if symbol is not in [0..3].

source§

unsafe fn occs_smaller_unchecked(&self, symbol: u8) -> usize

Returns the number of occurrences of all the symbols smaller than the input symbol in the indexed sequence.

Safety

Calling this method if the symbol is not in [0..3] is undefined behavior.

source§

unsafe fn rank_block_unchecked(&self, symbol: u8, i: usize) -> usize

Returns the rank of symbol up to the block that contains the position i.

Safety

Calling this method if the symbol is larger than 3 of if the position i is out of bound is undefined behavior.

source§

fn prefetch_info(&self, pos: usize)

Prefetches counters of the superblock and blocks containing the position pos.

source§

fn prefetch_data(&self, pos: usize)

Prefetches data containing the position pos.

source§

impl<S> StructuralPartialEq for RSQVector<S>

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for RSQVector<S>
where S: RefUnwindSafe,

§

impl<S> Send for RSQVector<S>
where S: Send,

§

impl<S> Sync for RSQVector<S>
where S: Sync,

§

impl<S> Unpin for RSQVector<S>
where S: Unpin,

§

impl<S> UnwindSafe for RSQVector<S>
where S: 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> RSforWT for T