39 |
|
* such damages. |
40 |
|
*/ |
41 |
|
|
42 |
– |
#include "utils/BitSet.hpp" |
42 |
|
#include <algorithm> |
43 |
|
#include <cassert> |
44 |
+ |
#include <string> |
45 |
|
|
46 |
+ |
#include "utils/BitSet.hpp" |
47 |
+ |
#include "utils/Algorithm.hpp" |
48 |
+ |
|
49 |
|
namespace oopse { |
50 |
|
int BitSet::countBits() { |
51 |
|
return std::count(bitset_.begin(), bitset_.end(), true); |
79 |
|
return i == bitset_.end() ? true : false; |
80 |
|
} |
81 |
|
|
82 |
< |
int BitSet::nextOffBit(int fromIndex) { |
82 |
> |
int BitSet::nextOffBit(int fromIndex) const { |
83 |
|
++fromIndex; |
84 |
|
while (fromIndex < size()) { |
85 |
|
if (!bitset_[fromIndex]) { |
91 |
|
return -1; |
92 |
|
} |
93 |
|
|
94 |
< |
int BitSet::nextOnBit(int fromIndex) { |
94 |
> |
int BitSet::nextOnBit(int fromIndex) const { |
95 |
|
++fromIndex; |
96 |
|
while (fromIndex < size()) { |
97 |
|
if (bitset_[fromIndex]) { |
171 |
|
} |
172 |
|
|
173 |
|
std::ostream& operator<< ( std::ostream& os, const BitSet& bs) { |
174 |
+ |
for (int i = 0; i < bs.bitset_.size(); ++i) { |
175 |
+ |
std::string val = bs[i] ? "true" : "false"; |
176 |
+ |
os << "BitSet[" << i <<"] = " << val << std::endl; |
177 |
+ |
} |
178 |
+ |
|
179 |
|
return os; |
180 |
|
} |
181 |
|
|