@@ -81,7 +81,7 @@ struct darray {
8181 darray () : m_positions(0 ) {}
8282
8383 void build (bit_vector const & B) {
84- std::vector< uint64_t > const & data = B.data ();
84+ auto const & data = B.data ();
8585 std::vector<uint64_t > cur_block_positions;
8686 std::vector<int64_t > block_inventory;
8787 std::vector<uint16_t > subblock_inventory;
@@ -113,9 +113,9 @@ struct darray {
113113 flush_cur_block (cur_block_positions, block_inventory, subblock_inventory,
114114 overflow_positions);
115115 }
116- m_block_inventory. swap (block_inventory);
117- m_subblock_inventory. swap (subblock_inventory);
118- m_overflow_positions. swap (overflow_positions);
116+ m_block_inventory = std::move (block_inventory);
117+ m_subblock_inventory = std::move (subblock_inventory);
118+ m_overflow_positions = std::move (overflow_positions);
119119
120120 // std::cout << "I: ";
121121 // for (auto x : m_block_inventory) { std::cout << x << ' '; }
@@ -174,7 +174,7 @@ struct darray {
174174 uint64_t reminder = i & (subblock_size - 1 );
175175 if (!reminder) return start_pos;
176176
177- std::vector< uint64_t > const & data = B.data ();
177+ auto const & data = B.data ();
178178 uint64_t word_idx = start_pos >> 6 ;
179179 uint64_t word_shift = start_pos & 63 ;
180180 uint64_t word = WordGetter ()(data, word_idx) & (uint64_t (-1 ) << word_shift);
@@ -214,9 +214,9 @@ struct darray {
214214
215215protected:
216216 uint64_t m_positions;
217- std::vector <int64_t > m_block_inventory;
218- std::vector <uint16_t > m_subblock_inventory;
219- std::vector <uint64_t > m_overflow_positions;
217+ essentials::owning_span <int64_t > m_block_inventory;
218+ essentials::owning_span <uint16_t > m_subblock_inventory;
219+ essentials::owning_span <uint64_t > m_overflow_positions;
220220
221221 template <typename Visitor, typename T>
222222 static void visit_impl (Visitor& visitor, T&& t) {
@@ -262,11 +262,13 @@ struct darray {
262262namespace util {
263263
264264struct identity_getter {
265- uint64_t operator ()(std::vector<uint64_t > const & data, uint64_t i) const { return data[i]; }
265+ template <typename Vec>
266+ uint64_t operator ()(Vec const & data, uint64_t i) const { return data[i]; }
266267};
267268
268269struct negating_getter {
269- uint64_t operator ()(std::vector<uint64_t > const & data, uint64_t i) const { return ~data[i]; }
270+ template <typename Vec>
271+ uint64_t operator ()(Vec const & data, uint64_t i) const { return ~data[i]; }
270272};
271273
272274} // namespace util
0 commit comments