- Even more TArray changes.

(patches by Graf)
This commit is contained in:
drfrag666 2018-11-12 21:12:57 +01:00
parent 63edabba16
commit 5740421d54

View file

@ -560,6 +560,10 @@ public:
{
return Array[index];
}
T &At(size_t index) const
{
return Array[index];
}
unsigned int Size() const
{
return Count;
@ -1221,3 +1225,73 @@ protected:
hash_t Position;
};
class BitArray
{
TArray<uint8_t> bytes;
unsigned size;
public:
void Resize(unsigned elem)
{
bytes.Resize((elem + 7) / 8);
size = elem;
}
BitArray() : size(0)
{
}
BitArray(const BitArray & arr)
{
bytes = arr.bytes;
size = arr.size;
}
BitArray &operator=(const BitArray & arr)
{
bytes = arr.bytes;
size = arr.size;
return *this;
}
BitArray(BitArray && arr)
{
bytes = std::move(arr.bytes);
size = arr.size;
arr.size = 0;
}
BitArray &operator=(BitArray && arr)
{
bytes = std::move(arr.bytes);
size = arr.size;
arr.size = 0;
return *this;
}
bool operator[](size_t index) const
{
return !!(bytes[index >> 3] & (1 << (index & 7)));
}
void Set(size_t index)
{
bytes[index >> 3] |= (1 << (index & 7));
}
void Clear(size_t index)
{
bytes[index >> 3] &= ~(1 << (index & 7));
}
unsigned Size() const
{
return size;
}
void Zero()
{
memset(&bytes[0], 0, bytes.Size());
}
};