# | Line 81 | Line 81 | class BitSet { | |
---|---|---|
81 | /** Returns true if no bits are set to true */ | |
82 | bool none(); | |
83 | ||
84 | < | int firstOffBit() { return !bitset_[0] ? 0 : nextOffBit(0); } |
84 | > | int firstOffBit() const { return !bitset_[0] ? 0 : nextOffBit(0); } |
85 | ||
86 | /** Returns the index of the first bit that is set to false that occurs on or after the specified starting index.*/ | |
87 | int nextOffBit(int fromIndex) const; | |
88 | ||
89 | < | int firstOnBit() { return bitset_[0] ? 0 : nextOnBit(0); } |
89 | > | int firstOnBit() const { return bitset_[0] ? 0 : nextOnBit(0); } |
90 | ||
91 | /** Returns the index of the first bit that is set to true that occurs on or after the specified starting index. */ | |
92 | int nextOnBit(int fromIndex) const; | |
# | Line 122 | Line 122 | class BitSet { | |
122 | BitSet& operator&= (const BitSet &bs) { andOperator (bs); return *this; } | |
123 | BitSet& operator|= (const BitSet &bs) { orOperator (bs); return *this; } | |
124 | BitSet& operator^= (const BitSet &bs) { xorOperator (bs); return *this; } | |
125 | + | BitSet& operator-= (const BitSet &bs) { |
126 | + | BitSet tmp = *this ^ bs; |
127 | + | *this &= tmp; |
128 | + | return *this; |
129 | + | } |
130 | + | |
131 | bool operator[] (int bitIndex) const { return bitset_[bitIndex]; } | |
132 | friend BitSet operator| (const BitSet& bs1, const BitSet& bs2); | |
133 | friend BitSet operator& (const BitSet& bs1, const BitSet& bs2); | |
134 | friend BitSet operator^ (const BitSet& bs1, const BitSet& bs2); | |
135 | + | friend BitSet operator- (const BitSet& bs1, const BitSet& bs2); |
136 | + | |
137 | friend bool operator== (const BitSet & bs1, const BitSet &bs2); | |
138 | ||
139 | < | friend std::istream& operator>> ( std::istream&, const BitSet& bs); |
139 | > | //friend std::istream& operator>> ( std::istream&, const BitSet& bs); |
140 | friend std::ostream& operator<< ( std::ostream&, const BitSet& bs) ; | |
141 | ||
142 | private: |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |