37 mBits.resize(capacity);
42 for (
const auto& b:
mBits) {
43 if (b != 0)
return false;
51 for (
const auto& b:
mBits) {
54 while( (elem &
unsigned(1)) == 0 )
66 void setBit(
unsigned pos,
bool val =
true) {
67 static_assert(
sizeof(
unsigned) == 4,
"Currently bitvectors are only supported on these platforms.");
68 unsigned vecElem = pos >> 5;
70 mask <<= (pos & unsigned(31));
71 if(vecElem >=
mBits.size()) {
72 mBits.resize(std::size_t(vecElem) + 1, 0);
76 mBits[vecElem] &= mask;
78 mBits[vecElem] |= mask;
80 assert(
getBit(pos) == val);
84 static_assert(
sizeof(
unsigned) == 4,
"Currently bitvectors are only supported on these platforms.");
85 unsigned vecElem = pos >> 5;
86 if(vecElem <
mBits.size()) {
87 unsigned bitNr = pos & unsigned(31);
88 return ((
mBits[vecElem] >> bitNr) &
unsigned(1)) != 0;
109 auto lhsIt =
mBits.begin();
110 auto rhsIt = rhs.
mBits.begin();
112 auto lhsEnd =
mBits.end();
113 auto rhsEnd = rhs.
mBits.end();
116 if(lhsIt == lhsEnd) {
117 mBits.insert(lhsIt,rhsIt,rhsEnd);
121 if(rhsIt == rhsEnd) {
136 forward_iterator(
const std::vector<unsigned>::const_iterator it,
const std::vector<unsigned>::const_iterator vectorEnd) :
142 std::vector<unsigned>::const_iterator
vecIter;
143 const std::vector<unsigned>::const_iterator
vecEnd;
183 void print(std::ostream& os = std::cout)
const {
carl is the main namespace for the library.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
constexpr unsigned sizeOfUnsigned
forward_iterator begin() const
bool subsetOf(const BitVector &superset)
size_t findFirstSetBit() const
bool getBit(unsigned pos) const
void print(std::ostream &os=std::cout) const
BitVector & calculateUnion(const BitVector &rhs)
friend BitVector operator|(const BitVector &lhs, const BitVector &rhs)
forward_iterator end() const
void setBit(unsigned pos, bool val=true)
friend bool operator==(const BitVector &lhs, const BitVector &rhs)
void reserve(size_t capacity)
BitVector & operator|=(const BitVector &rhs)
std::vector< unsigned > mBits
std::vector< unsigned >::const_iterator vecIter
friend bool operator==(const forward_iterator &fi1, const forward_iterator &fi2)
forward_iterator(const std::vector< unsigned >::const_iterator it, const std::vector< unsigned >::const_iterator vectorEnd)
forward_iterator operator++(int i)
const std::vector< unsigned >::const_iterator vecEnd