# | 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 80 | Line 81 | class BitSet { | |
81 | ||
82 | /** Returns true if no bits are set to true */ | |
83 | bool none(); | |
84 | + | |
85 | + | int firstOffBit() { return !bitset_[0] ? 0 : nextOffBit(0); } |
86 | ||
87 | /** Returns the index of the first bit that is set to false that occurs on or after the specified starting index.*/ | |
88 | < | int nextOffBit(int fromIndex); |
89 | < | |
88 | > | int nextOffBit(int fromIndex) const; |
89 | > | |
90 | > | int firstOnBit() { return bitset_[0] ? 0 : nextOnBit(0); } |
91 | > | |
92 | /** Returns the index of the first bit that is set to true that occurs on or after the specified starting index. */ | |
93 | < | int nextOnBit(int fromIndex); |
93 | > | int nextOnBit(int fromIndex) const; |
94 | ||
95 | /** Performs a logical AND of this target bit set with the argument bit set. */ | |
96 | void andOperator (const BitSet& bs); | |
# | Line 118 | Line 123 | class BitSet { | |
123 | BitSet& operator&= (const BitSet &bs) { andOperator (bs); return *this; } | |
124 | BitSet& operator|= (const BitSet &bs) { orOperator (bs); return *this; } | |
125 | BitSet& operator^= (const BitSet &bs) { xorOperator (bs); return *this; } | |
126 | < | bool operator[] (int bitIndex) { return bitset_[bitIndex]; } |
122 | < | |
126 | > | bool operator[] (int bitIndex) const { return bitset_[bitIndex]; } |
127 | friend BitSet operator| (const BitSet& bs1, const BitSet& bs2); | |
128 | friend BitSet operator& (const BitSet& bs1, const BitSet& bs2); | |
129 | friend BitSet operator^ (const BitSet& bs1, const BitSet& bs2); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |