Struct bio::data_structures::smallints::SmallInts
source · pub struct SmallInts<F: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> { /* private fields */ }
Expand description
Data structure for storing a sequence of small integers with few big ones space efficiently while supporting classical vector operations.
Implementations§
source§impl<S: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> SmallInts<S, B>
impl<S: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> SmallInts<S, B>
sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create a new instance with a given capacity.
sourcepub fn from_elem(v: S, n: usize) -> Self
pub fn from_elem(v: S, n: usize) -> Self
Create a new instance containing n
times the integer v
(and v
is expected to be small).
sourcepub fn get(&self, i: usize) -> Option<B>
pub fn get(&self, i: usize) -> Option<B>
Return the integer at position i
. Time complexity O(1)
if i
points to a small int,
O(log(b))
for a big int, where b
denotes the number of big ints stored.
sourcepub fn push(&mut self, v: B)
pub fn push(&mut self, v: B)
Append v
to the sequence. This will determine whether v
is big or small and store it
accordingly. Time complexity O(1)
for small ints and O(log(b))
for big ints,
where b
denotes the number of big ints stored.
sourcepub fn set(&mut self, i: usize, v: B)
pub fn set(&mut self, i: usize, v: B)
Set value of position i
to v
. This will determine whether v
is big or small and store it accordingly.
Time complexity O(1)
for small ints and O(log(b))
for big ints,
where b
denotes the number of big ints stored.
sourcepub fn iter(&self) -> Iter<'_, S, B> ⓘ
pub fn iter(&self) -> Iter<'_, S, B> ⓘ
Iterate over sequence. Values will be returned in the big integer type (B
).
sourcepub fn decompress(&self) -> Vec<B>
pub fn decompress(&self) -> Vec<B>
Decompress into a normal vector of big integers (type B
).
Trait Implementations§
source§impl<F: Clone + Integer + Bounded + NumCast + Copy, B: Clone + Integer + NumCast + Copy> Clone for SmallInts<F, B>
impl<F: Clone + Integer + Bounded + NumCast + Copy, B: Clone + Integer + NumCast + Copy> Clone for SmallInts<F, B>
source§impl<F: Debug + Integer + Bounded + NumCast + Copy, B: Debug + Integer + NumCast + Copy> Debug for SmallInts<F, B>
impl<F: Debug + Integer + Bounded + NumCast + Copy, B: Debug + Integer + NumCast + Copy> Debug for SmallInts<F, B>
source§impl<S: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> Default for SmallInts<S, B>
impl<S: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> Default for SmallInts<S, B>
source§impl<'de, F, B> Deserialize<'de> for SmallInts<F, B>where
F: Deserialize<'de> + Integer + Bounded + NumCast + Copy,
B: Deserialize<'de> + Integer + NumCast + Copy,
impl<'de, F, B> Deserialize<'de> for SmallInts<F, B>where F: Deserialize<'de> + Integer + Bounded + NumCast + Copy, B: Deserialize<'de> + Integer + NumCast + Copy,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<F: Hash + Integer + Bounded + NumCast + Copy, B: Hash + Integer + NumCast + Copy> Hash for SmallInts<F, B>
impl<F: Hash + Integer + Bounded + NumCast + Copy, B: Hash + Integer + NumCast + Copy> Hash for SmallInts<F, B>
source§impl<F: Ord + Integer + Bounded + NumCast + Copy, B: Ord + Integer + NumCast + Copy> Ord for SmallInts<F, B>
impl<F: Ord + Integer + Bounded + NumCast + Copy, B: Ord + Integer + NumCast + Copy> Ord for SmallInts<F, B>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<F: PartialEq + Integer + Bounded + NumCast + Copy, B: PartialEq + Integer + NumCast + Copy> PartialEq<SmallInts<F, B>> for SmallInts<F, B>
impl<F: PartialEq + Integer + Bounded + NumCast + Copy, B: PartialEq + Integer + NumCast + Copy> PartialEq<SmallInts<F, B>> for SmallInts<F, B>
source§impl<F: PartialOrd + Integer + Bounded + NumCast + Copy, B: PartialOrd + Integer + NumCast + Copy> PartialOrd<SmallInts<F, B>> for SmallInts<F, B>
impl<F: PartialOrd + Integer + Bounded + NumCast + Copy, B: PartialOrd + Integer + NumCast + Copy> PartialOrd<SmallInts<F, B>> for SmallInts<F, B>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<F, B> Serialize for SmallInts<F, B>where
F: Serialize + Integer + Bounded + NumCast + Copy,
B: Serialize + Integer + NumCast + Copy,
impl<F, B> Serialize for SmallInts<F, B>where F: Serialize + Integer + Bounded + NumCast + Copy, B: Serialize + Integer + NumCast + Copy,
impl<F: Eq + Integer + Bounded + NumCast + Copy, B: Eq + Integer + NumCast + Copy> Eq for SmallInts<F, B>
impl<F: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> StructuralEq for SmallInts<F, B>
impl<F: Integer + Bounded + NumCast + Copy, B: Integer + NumCast + Copy> StructuralPartialEq for SmallInts<F, B>
Auto Trait Implementations§
impl<F, B> RefUnwindSafe for SmallInts<F, B>where B: RefUnwindSafe, F: RefUnwindSafe,
impl<F, B> Send for SmallInts<F, B>where B: Send, F: Send,
impl<F, B> Sync for SmallInts<F, B>where B: Sync, F: Sync,
impl<F, B> Unpin for SmallInts<F, B>where F: Unpin,
impl<F, B> UnwindSafe for SmallInts<F, B>where B: RefUnwindSafe, F: 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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.