#ifndef __BitSet_h_ #define __BitSet_h_ #include #include ///////////////////////////////////////////////////////////////////// // BitSet is basically a set of unsigned integers, with a few // convenience functions. The interpretation is an unsigned integer // of arbitrary size. 0 is the least significan bit. ///////////////////////////////////////////////////////////////////// class BitSet { private: std::set< unsigned > _bits; public: bool get(unsigned bit) const; unsigned max() const; // The largest bit that is set or 0 if no bit it set. void set(unsigned bit, bool value = true); void clear(unsigned bit); void clear(); BitSet(); BitSet(std::string asHex); void loadFromHex(std::string asHex); std::string asHex() const; std::string asBinary() const; int size() const { return _bits.size(); } typedef std::set< unsigned >::const_iterator const_iterator; const_iterator begin() const { return _bits.begin(); } const_iterator end() const { return _bits.end(); } BitSet &operator &=(BitSet const &other); bool operator ==(BitSet const &other) const { return _bits == other._bits; } bool empty() const { return _bits.empty(); } }; #endif