# | Line 42 | Line 42 | |
---|---|---|
42 | #ifndef UTILS_BITSET_HPP | |
43 | #define UTILS_BITSET_HPP | |
44 | ||
45 | + | #include <iostream> |
46 | #include <functional> | |
47 | #include <vector> | |
48 | namespace oopse { | |
# | Line 55 | Line 56 | class BitSet { | |
56 | /** */ | |
57 | BitSet() {} | |
58 | /** */ | |
59 | < | BitSet(int nbits) { bitset_.resize(nbits); } |
59 | > | BitSet(int nbits) : bitset_(nbits) {clearAll(); } |
60 | ||
61 | /** Returns the number of bits set to true in this BitSet. */ | |
62 | int countBits(); | |
# | Line 82 | Line 83 | class BitSet { | |
83 | bool none(); | |
84 | ||
85 | /** Returns the index of the first bit that is set to false that occurs on or after the specified starting index.*/ | |
86 | < | int nextOffBit(int fromIndex); |
86 | > | int nextOffBit(int fromIndex) const; |
87 | ||
88 | /** Returns the index of the first bit that is set to true that occurs on or after the specified starting index. */ | |
89 | < | int nextOnBit(int fromIndex); |
89 | > | int nextOnBit(int fromIndex) const; |
90 | ||
91 | /** Performs a logical AND of this target bit set with the argument bit set. */ | |
92 | void andOperator (const BitSet& bs); | |
# | Line 118 | Line 119 | class BitSet { | |
119 | BitSet& operator&= (const BitSet &bs) { andOperator (bs); return *this; } | |
120 | BitSet& operator|= (const BitSet &bs) { orOperator (bs); return *this; } | |
121 | BitSet& operator^= (const BitSet &bs) { xorOperator (bs); return *this; } | |
122 | < | bool operator[] (int bitIndex) { return bitset_[bitIndex]; } |
122 | < | |
122 | > | bool operator[] (int bitIndex) const { return bitset_[bitIndex]; } |
123 | friend BitSet operator| (const BitSet& bs1, const BitSet& bs2); | |
124 | friend BitSet operator& (const BitSet& bs1, const BitSet& bs2); | |
125 | friend BitSet operator^ (const BitSet& bs1, const BitSet& bs2); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |