Commit cb0fd07e authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #1162 from corona10/bitset_begin

bitset begin() function fix
parents 3ed04ee9 4bdc3989
...@@ -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