GF2::Vector — Storage Capacity

constexpr std::size_t capacity() const;   (1)
constexpr std::size_t unused() const;     (2)
1 Returns the number of elements the bit-vector is capable of storing in its current state.
2 Returns the spare capacity in the bit-vector in its current state i.e. capacity() - size().

It is often the case for bit-vectors that we aren’t using all storage at our disposal. For example, if we construct a small GF2::Vector with say 8 elements and use the default Block of uint64_t we will have at least a single block of storage so a capacity of 64. This means we have 56 spare slots and can append 56 more elements to the vector before needing to allocate any more storage.

Example
#include <GF2/GF2.h>
int main()
{
    GF2::Vector<> v("10101010");
    std::cout << "Vector " << v << ": "
              << "size " << v.size() << ", capacity " << v.capacity() << ", unused capacity " << v.unused() << ".\n";
}
Output
Vector 10101010: size 8, capacity 64, unused capacity 56.
See Also

reserve
description