MCPcopy Create free account
hub / github.com/comaps/comaps / LeaveFirstSetNBits

Method LeaveFirstSetNBits

libs/coding/compressed_bit_vector.cpp:301–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301unique_ptr<CompressedBitVector> DenseCBV::LeaveFirstSetNBits(uint64_t n) const
302{
303 if (PopCount() <= n)
304 return Clone();
305
306 vector<uint64_t> groups;
307 for (size_t i = 0; i < m_bitGroups.size() && n != 0; ++i)
308 {
309 uint64_t group = m_bitGroups[i];
310 uint32_t const bits = std::popcount(group);
311 if (bits <= n)
312 {
313 n -= bits;
314 groups.push_back(group);
315 }
316 else
317 {
318 uint64_t part = 0;
319 while (n != 0)
320 {
321 part = part | (group & -group);
322 group = group & (group - 1);
323 --n;
324 }
325 groups.push_back(part);
326 }
327 }
328 return CompressedBitVectorBuilder::FromBitGroups(std::move(groups));
329}
330
331CompressedBitVector::StorageStrategy DenseCBV::GetStorageStrategy() const
332{

Callers 2

UNIT_TESTFunction · 0.80
TakeMethod · 0.80

Calls 4

popcountFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64