#include <genesis/utils/math/twobit_vector.hpp>
Definition at line 41 of file twobit_vector.hpp.
Public Member Functions | |
TwobitVector ()=default | |
TwobitVector (size_t size) | |
Constructor that initializes the vector with size many zero values. More... | |
TwobitVector (TwobitVector &&)=default | |
TwobitVector (TwobitVector const &)=default | |
~TwobitVector ()=default | |
void | clear () |
Clear the vector, so that it contains no data. More... | |
WordType & | data_at (size_t index) |
Return a single word of the vector. More... | |
WordType const & | data_at (size_t index) const |
Return a single word of the vector. More... | |
size_t | data_size () const |
Return the number of words (of type WordType) that are used to store the values in the vector. More... | |
ValueType | get (size_t index) const |
Get the value at a position in the vector. More... | |
WordType | hash () const |
Calculate a hash value of the vector, based on its size() and the xor of all its words. More... | |
void | insert_at (size_t index, ValueType value) |
Insert a value at a position. More... | |
bool | operator!= (TwobitVector const &other) const |
Inequality operator, opposite of operator==(). More... | |
TwobitVector & | operator= (TwobitVector &&)=default |
TwobitVector & | operator= (TwobitVector const &)=default |
bool | operator== (TwobitVector const &other) const |
Equality operator. More... | |
ValueType | operator[] (size_t index) const |
Alias for get(). More... | |
void | remove_at (size_t index) |
Remove the value at a position. More... | |
void | set (size_t index, ValueType value) |
Set a value at a position in the vector. More... | |
size_t | size () const |
Return the size of the vector, that is, how many values (of type ValueType) it currently holds. More... | |
bool | validate () const |
Validation function that checks some basic invariants. More... | |
Public Types | |
enum | ValueType : WordType { A = 0, C = 1, G = 2, T = 3 } |
Value Type enumeration for the elements of a TwobitVector. More... | |
using | WordType = uint64_t |
Underlying word type for the bitvector. More... | |
Static Public Attributes | |
static const size_t | kValuesPerWord = sizeof( WordType ) * 8 / 2 |
Constant that holds the number of values (of tyoe ValueType) that are stored in a single word in the vector. More... | |
|
default |
TwobitVector | ( | size_t | size | ) |
Constructor that initializes the vector with size
many zero values.
Definition at line 118 of file twobit_vector.cpp.
|
default |
|
default |
|
default |
void clear | ( | ) |
Clear the vector, so that it contains no data.
Definition at line 405 of file twobit_vector.cpp.
TwobitVector::WordType & data_at | ( | size_t | index | ) |
Return a single word of the vector.
This is useful for external functions that want to directly work on the underlying bit representation.
Definition at line 187 of file twobit_vector.cpp.
TwobitVector::WordType const & data_at | ( | size_t | index | ) | const |
Return a single word of the vector.
This is useful for external functions that want to directly work on the underlying bit representation.
Definition at line 176 of file twobit_vector.cpp.
size_t data_size | ( | ) | const |
Return the number of words (of type WordType) that are used to store the values in the vector.
Definition at line 140 of file twobit_vector.cpp.
TwobitVector::ValueType get | ( | size_t | index | ) | const |
Get the value at a position in the vector.
Definition at line 149 of file twobit_vector.cpp.
TwobitVector::WordType hash | ( | ) | const |
Calculate a hash value of the vector, based on its size() and the xor of all its words.
This is a simple function, but might just be enough for using it in a hashmap.
Definition at line 198 of file twobit_vector.cpp.
void insert_at | ( | size_t | index, |
TwobitVector::ValueType | value | ||
) |
Insert a value at a position.
The size() is increased by one.
Definition at line 290 of file twobit_vector.cpp.
bool operator!= | ( | TwobitVector const & | other | ) | const |
Inequality operator, opposite of operator==().
Definition at line 230 of file twobit_vector.cpp.
|
default |
|
default |
bool operator== | ( | TwobitVector const & | other | ) | const |
Equality operator.
Definition at line 214 of file twobit_vector.cpp.
TwobitVector::ValueType operator[] | ( | size_t | index | ) | const |
Alias for get().
Definition at line 165 of file twobit_vector.cpp.
void remove_at | ( | size_t | index | ) |
Remove the value at a position.
The size() is decreased by one.
Definition at line 342 of file twobit_vector.cpp.
void set | ( | size_t | index, |
TwobitVector::ValueType | value | ||
) |
Set a value at a position in the vector.
Definition at line 269 of file twobit_vector.cpp.
size_t size | ( | ) | const |
Return the size of the vector, that is, how many values (of type ValueType) it currently holds.
Definition at line 131 of file twobit_vector.cpp.
bool validate | ( | ) | const |
Validation function that checks some basic invariants.
This is mainly useful in testing. The function checks whether the vector is correctly sized and contains zero padding at its end.
Definition at line 241 of file twobit_vector.cpp.
using WordType = uint64_t |
Underlying word type for the bitvector.
We use 64bit words to store the 2bit values (of type ValueType), so that we get best speed on modern architectures.
Definition at line 55 of file twobit_vector.hpp.
Value Type enumeration for the elements of a TwobitVector.
The values 0-3 are named A
, C
, G
and T
, respectively, in order to ease the use with nucleotide sequences.
The underlying value of the enum is WordType, so that a cast does not need to convert internally.
Enumerator | |
---|---|
A | |
C | |
G | |
T |
Definition at line 66 of file twobit_vector.hpp.
|
static |
Constant that holds the number of values (of tyoe ValueType) that are stored in a single word in the vector.
As we use 64bit words, this value is 32.
Definition at line 79 of file twobit_vector.hpp.