43 |
|
#include <algorithm> |
44 |
|
#include <cassert> |
45 |
|
#include <string> |
46 |
+ |
#include <iterator> |
47 |
|
|
48 |
|
#include "utils/OpenMDBitSet.hpp" |
49 |
|
#include "utils/Algorithm.hpp" |
65 |
|
assert(fromIndex <= toIndex); |
66 |
|
assert(fromIndex >=0); |
67 |
|
assert(toIndex <= size()); |
68 |
< |
std::vector<char>::iterator first = bitset_.begin() + fromIndex; |
69 |
< |
std::vector<char>::iterator last = bitset_.begin() + toIndex; |
68 |
> |
std::vector<bool>::iterator first = bitset_.begin() + fromIndex; |
69 |
> |
std::vector<bool>::iterator last = bitset_.begin() + toIndex; |
70 |
|
|
71 |
|
std::transform(first, last, first, std::logical_not<bool>()); |
72 |
|
|
76 |
|
assert(fromIndex <= toIndex); |
77 |
|
assert(fromIndex >=0); |
78 |
|
assert(toIndex <= size()); |
79 |
< |
std::vector<char>::iterator first = bitset_.begin() + fromIndex; |
80 |
< |
std::vector<char>::iterator last = bitset_.begin() + toIndex; |
79 |
> |
std::vector<bool>::iterator first = bitset_.begin() + fromIndex; |
80 |
> |
std::vector<bool>::iterator last = bitset_.begin() + toIndex; |
81 |
|
|
82 |
|
OpenMDBitSet result; |
83 |
|
std::copy(first, last, std::back_inserter(result.bitset_)); |
85 |
|
} |
86 |
|
|
87 |
|
bool OpenMDBitSet::none() { |
88 |
< |
std::vector<char>::iterator i = std::find(bitset_.begin(), bitset_.end(), true); |
88 |
> |
std::vector<bool>::iterator i = std::find(bitset_.begin(), bitset_.end(), true); |
89 |
|
return i == bitset_.end() ? true : false; |
90 |
|
} |
91 |
|
|
143 |
|
assert(fromIndex <= toIndex); |
144 |
|
assert(fromIndex >=0); |
145 |
|
assert(toIndex <= size()); |
146 |
< |
std::vector<char>::iterator first = bitset_.begin() + fromIndex; |
147 |
< |
std::vector<char>::iterator last = bitset_.begin() + toIndex; |
146 |
> |
std::vector<bool>::iterator first = bitset_.begin() + fromIndex; |
147 |
> |
std::vector<bool>::iterator last = bitset_.begin() + toIndex; |
148 |
|
std::fill(first, last, value); |
149 |
|
} |
150 |
|
|
199 |
|
//} |
200 |
|
|
201 |
|
std::ostream& operator<< ( std::ostream& os, const OpenMDBitSet& bs) { |
202 |
< |
for (int i = 0; i < bs.bitset_.size(); ++i) { |
202 |
> |
for (unsigned int i = 0; i < bs.bitset_.size(); ++i) { |
203 |
|
std::string val = bs[i] ? "true" : "false"; |
204 |
|
os << "OpenMDBitSet[" << i <<"] = " << val << std::endl; |
205 |
|
} |