Commit 4bdc3989 authored by Dong-hee Na's avatar Dong-hee Na

bitset begin() fix

parent b163e6cd
...@@ -181,9 +181,10 @@ template <int N> struct BitSet { ...@@ -181,9 +181,10 @@ template <int N> struct BitSet {
} }
iterator begin() const { iterator begin() const {
uint16_t tmp = bits; uint16_t tmp = bits;
for (int i = 0; i < N; i++) { if (tmp > 0) {
if (tmp & 1) int offset = __builtin_ctz(tmp);
return iterator(*this, i); if (offset < N)
return iterator(*this, offset);
} }
return iterator(*this, N); return iterator(*this, N);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment