69 3ul << 0, 3ul << 2, 3ul << 4, 3ul << 6, 3ul << 8, 3ul << 10, 3ul << 12, 3ul << 14,
70 3ul << 16, 3ul << 18, 3ul << 20, 3ul << 22, 3ul << 24, 3ul << 26, 3ul << 28, 3ul << 30,
71 3ul << 32, 3ul << 34, 3ul << 36, 3ul << 38, 3ul << 40, 3ul << 42, 3ul << 44, 3ul << 46,
72 3ul << 48, 3ul << 50, 3ul << 52, 3ul << 54, 3ul << 56, 3ul << 58, 3ul << 60, 3ul << 62
93 TwobitVector::all_0_, TwobitVector::all_1_ >> 62,
94 TwobitVector::all_1_ >> 60, TwobitVector::all_1_ >> 58,
95 TwobitVector::all_1_ >> 56, TwobitVector::all_1_ >> 54,
96 TwobitVector::all_1_ >> 52, TwobitVector::all_1_ >> 50,
97 TwobitVector::all_1_ >> 48, TwobitVector::all_1_ >> 46,
98 TwobitVector::all_1_ >> 44, TwobitVector::all_1_ >> 42,
99 TwobitVector::all_1_ >> 40, TwobitVector::all_1_ >> 38,
100 TwobitVector::all_1_ >> 36, TwobitVector::all_1_ >> 34,
101 TwobitVector::all_1_ >> 32, TwobitVector::all_1_ >> 30,
102 TwobitVector::all_1_ >> 28, TwobitVector::all_1_ >> 26,
103 TwobitVector::all_1_ >> 24, TwobitVector::all_1_ >> 22,
104 TwobitVector::all_1_ >> 20, TwobitVector::all_1_ >> 18,
105 TwobitVector::all_1_ >> 16, TwobitVector::all_1_ >> 14,
106 TwobitVector::all_1_ >> 12, TwobitVector::all_1_ >> 10,
107 TwobitVector::all_1_ >> 8, TwobitVector::all_1_ >> 6,
108 TwobitVector::all_1_ >> 4, TwobitVector::all_1_ >> 2
120 , data_( ( size / kValuesPerWord ) + ( size % kValuesPerWord == 0 ? 0 : 1 ), 0 )
151 if (index >= size_) {
152 throw std::out_of_range(
"TwobitVector::get: Invalid index." );
178 return data_.at( index );
189 return data_.at( index );
201 for(
auto s : data_ ) {
216 if( size_ != other.size_ ) {
219 for(
size_t i = 0; i < data_.size(); ++i ) {
220 if( data_[i] != other.data_[i] ) {
232 return !(*
this == other);
245 LOG_INFO <<
"Sizes does not match.";
253 && (( data_.back() & ~ ones_mask_[ size_ %
kValuesPerWord ] ) != 0ul )
255 LOG_INFO <<
"Invalid padding bits.";
271 if( index >= size_ ) {
272 throw std::out_of_range(
"TwobitVector::set: Invalid index." );
292 if( index > size_ ) {
293 throw std::out_of_range(
"TwobitVector::insert_at: Invalid index." );
302 data_.push_back( 0ul );
306 for(
size_t i = data_.size() - 1; i > word_id; --i ) {
315 auto bleed = data_[ i - 1 ] >> (
sizeof(
WordType ) * 8 - 2 );
323 auto const remainder = data_[ word_id ] & ( ~ ones_mask_[ segm_id ] );
326 data_[ word_id ] &= ones_mask_[ segm_id ];
329 data_[ word_id ] |= ( remainder << 2 );
332 auto const val_shifted =
static_cast< WordType >( value ) << ( 2 * segm_id );
333 data_[ word_id ] |= val_shifted;
344 if( index >= size_ ) {
345 throw std::out_of_range(
"TwobitVector::remove_at: Invalid index." );
356 auto remainder = data_[ word_id ] & ( ~ ones_mask_[ segm_id + 1 ] );
359 data_[ word_id ] &= ones_mask_[ segm_id ];
362 data_[ word_id ] |= ( remainder >> 2 );
367 data_[ word_id ] &= ones_mask_[ segm_id ];
371 if( word_id < data_.size() - 1 ) {
375 auto bleed = data_[ word_id + 1 ] << (
sizeof(
WordType ) * 8 - 2 );
376 data_[ word_id ] |= bleed;
379 for(
size_t i = word_id + 1; i < data_.size() - 1; ++i ) {
380 bleed = data_[ i + 1 ] << (
sizeof(
WordType ) * 8 - 2 );
void insert_at(size_t index, ValueType value)
Insert a value at a position.
size_t size() const
Return the size of the vector, that is, how many values (of type ValueType) it currently holds...
ValueType get(size_t index) const
Get the value at a position in the vector.
bool operator==(TwobitVector const &other) const
Equality operator.
static const size_t kValuesPerWord
Constant that holds the number of values (of tyoe ValueType) that are stored in a single word in the ...
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
void remove_at(size_t index)
Remove the value at a position.
WordType hash() const
Calculate a hash value of the vector, based on its size() and the xor of all its words.
uint64_t WordType
Underlying word type for the bitvector.
void set(size_t index, ValueType value)
Set a value at a position in the vector.
Provides easy and fast logging functionality.
bool operator!=(TwobitVector const &other) const
Inequality operator, opposite of operator==().
ValueType operator[](size_t index) const
Alias for get().
void clear()
Clear the vector, so that it contains no data.
bool validate() const
Validation function that checks some basic invariants.
ValueType
Value Type enumeration for the elements of a TwobitVector.
size_t data_size() const
Return the number of words (of type WordType) that are used to store the values in the vector...
WordType const & data_at(size_t index) const
Return a single word of the vector.
#define LOG_INFO
Log an info message. See genesis::utils::LoggingLevel.