6 #if !defined(HSDS_BIT_VECTOR_H_)
7 #define HSDS_BIT_VECTOR_H_
13 #include "hsds/vector.hpp"
14 #include "hsds/rank-index.hpp"
18 #define FORCE_INLINE __forceinline
22 #define FORCE_INLINE inline __attribute__((always_inline))
33 const uint32_t S_BLOCK_SIZE = 64;
34 const uint32_t L_BLOCK_SIZE = 512;
35 const uint32_t BLOCK_RATE = 8;
37 const char*
const E_OUT_OF_RANGE =
"Out of range access";
38 const char*
const E_SAVE_FILE =
"Failed to save the bit vector.";
39 const char*
const E_LOAD_FILE =
"Failed to read file. File format is invalid.";
95 void set(uint64_t i,
bool b =
true);
120 uint64_t
get_bits(uint64_t pos, uint64_t len)
const;
129 void build(
bool enable_faster_select1 =
false,
bool enable_faster_select0 =
false);
148 return b ? (num_of_1s_) : (size_ - num_of_1s_);
180 uint64_t
rank0(uint64_t i)
const;
189 uint64_t
rank1(uint64_t i)
const;
210 uint64_t
select0(uint64_t x)
const;
219 uint64_t
select1(uint64_t x)
const;
259 typedef uint64_t block_type;
260 typedef hsds::Vector<block_type> blocks_type;
261 typedef hsds::Vector<RankIndex> rank_dict_type;
262 typedef hsds::Vector<uint32_t> select_dict_type;
265 rank_dict_type rank_table_;
266 select_dict_type select0_table_;
267 select_dict_type select1_table_;