unsigned Size; // Size of bitvector in bits.
public:
- typedef unsigned size_type;
+ using size_type = unsigned;
// Encapsulation of a single bit.
class reference {
[&Arg](auto const &BV) { return Arg.size() == BV; }) &&
"consistent sizes");
Out.resize(Arg.size());
- for (size_t i = 0, e = Arg.Bits.size(); i != e; ++i)
- Out.Bits[i] = f(Arg.Bits[i], Args.Bits[i]...);
+ for (size_type I = 0, E = Arg.Bits.size(); I != E; ++I)
+ Out.Bits[I] = f(Arg.Bits[I], Args.Bits[I]...);
Out.clear_unused_bits();
return Out;
}
BitVector &operator|=(const BitVector &RHS) {
if (size() < RHS.size())
resize(RHS.size());
- for (size_t i = 0, e = RHS.Bits.size(); i != e; ++i)
- Bits[i] |= RHS.Bits[i];
+ for (size_type I = 0, E = RHS.Bits.size(); I != E; ++I)
+ Bits[I] |= RHS.Bits[I];
return *this;
}
BitVector &operator^=(const BitVector &RHS) {
if (size() < RHS.size())
resize(RHS.size());
- for (size_t i = 0, e = RHS.Bits.size(); i != e; ++i)
- Bits[i] ^= RHS.Bits[i];
+ for (size_type I = 0, E = RHS.Bits.size(); I != E; ++I)
+ Bits[I] ^= RHS.Bits[I];
return *this;
}
public:
/// Return the size (in bytes) of the bit vector.
- size_t getMemorySize() const { return Bits.size() * sizeof(BitWord); }
- size_t getBitCapacity() const { return Bits.size() * BITWORD_SIZE; }
+ size_type getMemorySize() const { return Bits.size() * sizeof(BitWord); }
+ size_type getBitCapacity() const { return Bits.size() * BITWORD_SIZE; }
};
-inline size_t capacity_in_bytes(const BitVector &X) {
+inline BitVector::size_type capacity_in_bytes(const BitVector &X) {
return X.getMemorySize();
}
return V;
}
static unsigned getHashValue(const BitVector &V) {
- return DenseMapInfo<std::pair<unsigned, ArrayRef<uintptr_t>>>::getHashValue(
- std::make_pair(V.size(), V.getData()));
+ return DenseMapInfo<std::pair<BitVector::size_type, ArrayRef<uintptr_t>>>::
+ getHashValue(std::make_pair(V.size(), V.getData()));
}
static bool isEqual(const BitVector &LHS, const BitVector &RHS) {
if (LHS.isInvalid() || RHS.isInvalid())
"Unsupported word size");
public:
- using size_type = unsigned;
+ using size_type = uintptr_t;
// Encapsulation of a single bit.
class reference {
return reinterpret_cast<BitVector *>(X);
}
- void switchToSmall(uintptr_t NewSmallBits, size_t NewSize) {
+ void switchToSmall(uintptr_t NewSmallBits, size_type NewSize) {
X = 1;
setSmallSize(NewSize);
setSmallBits(NewSmallBits);
}
// Return the size.
- size_t getSmallSize() const { return getSmallRawBits() >> SmallNumDataBits; }
+ size_type getSmallSize() const {
+ return getSmallRawBits() >> SmallNumDataBits;
+ }
- void setSmallSize(size_t Size) {
+ void setSmallSize(size_type Size) {
setSmallRawBits(getSmallBits() | (Size << SmallNumDataBits));
}
}
/// Returns the number of bits in this bitvector.
- size_t size() const {
+ size_type size() const {
return isSmall() ? getSmallSize() : getPointer()->size();
}
} else {
BitVector *BV = new BitVector(N, t);
uintptr_t OldBits = getSmallBits();
- for (size_t i = 0, e = getSmallSize(); i != e; ++i)
- (*BV)[i] = (OldBits >> i) & 1;
+ for (size_type I = 0, E = getSmallSize(); I != E; ++I)
+ (*BV)[I] = (OldBits >> I) & 1;
switchToLarge(BV);
}
}
if (isSmall()) {
if (N > SmallNumDataBits) {
uintptr_t OldBits = getSmallRawBits();
- size_t SmallSize = getSmallSize();
+ size_type SmallSize = getSmallSize();
BitVector *BV = new BitVector(SmallSize);
- for (size_t i = 0; i < SmallSize; ++i)
- if ((OldBits >> i) & 1)
- BV->set(i);
+ for (size_type I = 0; I < SmallSize; ++I)
+ if ((OldBits >> I) & 1)
+ BV->set(I);
BV->reserve(N);
switchToLarge(BV);
}
else if (!isSmall() && !RHS.isSmall())
return *getPointer() == *RHS.getPointer();
else {
- for (size_t i = 0, e = size(); i != e; ++i) {
- if ((*this)[i] != RHS[i])
+ for (size_type I = 0, E = size(); I != E; ++I) {
+ if ((*this)[I] != RHS[I])
return false;
}
return true;
else if (!isSmall() && !RHS.isSmall())
getPointer()->operator&=(*RHS.getPointer());
else {
- size_t i, e;
- for (i = 0, e = std::min(size(), RHS.size()); i != e; ++i)
- (*this)[i] = test(i) && RHS.test(i);
- for (e = size(); i != e; ++i)
- reset(i);
+ size_type I, E;
+ for (I = 0, E = std::min(size(), RHS.size()); I != E; ++I)
+ (*this)[I] = test(I) && RHS.test(I);
+ for (E = size(); I != E; ++I)
+ reset(I);
}
return *this;
}
else if (!isSmall() && !RHS.isSmall())
getPointer()->operator|=(*RHS.getPointer());
else {
- for (size_t i = 0, e = RHS.size(); i != e; ++i)
- (*this)[i] = test(i) || RHS.test(i);
+ for (size_type I = 0, E = RHS.size(); I != E; ++I)
+ (*this)[I] = test(I) || RHS.test(I);
}
return *this;
}
else if (!isSmall() && !RHS.isSmall())
getPointer()->operator^=(*RHS.getPointer());
else {
- for (size_t i = 0, e = RHS.size(); i != e; ++i)
- (*this)[i] = test(i) != RHS.test(i);
+ for (size_type I = 0, E = RHS.size(); I != E; ++I)
+ (*this)[I] = test(I) != RHS.test(I);
}
return *this;
}
}
static unsigned getHashValue(const SmallBitVector &V) {
uintptr_t Store;
- return DenseMapInfo<std::pair<size_t, ArrayRef<uintptr_t>>>::getHashValue(
- std::make_pair(V.size(), V.getData(Store)));
+ return DenseMapInfo<
+ std::pair<SmallBitVector::size_type, ArrayRef<uintptr_t>>>::
+ getHashValue(std::make_pair(V.size(), V.getData(Store)));
}
static bool isEqual(const SmallBitVector &LHS, const SmallBitVector &RHS) {
if (LHS.isInvalid() || RHS.isInvalid())