Skip to content

Commit

Permalink
generalize bit_vector::enumerator::skip_zeros to runs of more than 64…
Browse files Browse the repository at this point in the history
… bits
  • Loading branch information
ot committed Jan 21, 2013
1 parent 00b6fd9 commit 8dff0c4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bit_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,23 @@ namespace succinct {
return val;
}

inline uint8_t skip_zeros()
inline uint64_t skip_zeros()
{
unsigned long l;
if (!broadword::lsb(m_buf, l)) {
uint64_t zs = 0;
// XXX the loop may be optimized by aligning access
while (!m_buf) {
m_pos += m_avail;
zs += m_avail;
m_avail = 0;
fill_buf();
uint8_t ret = broadword::lsb(m_buf, l);
assert(ret); (void)ret;
}

uint64_t l = broadword::lsb(m_buf);
m_buf >>= l;
m_buf >>= 1;
m_avail -= l + 1;
m_pos += l + 1;
return (uint8_t)l;
return zs + l;
}

private:
Expand Down

0 comments on commit 8dff0c4

Please sign in to comment.