GF2::Vector — Add/Remove ELements
Adds/removes single elements from the end of the bit-vector.
constexpr Vector &push(bool one = false); (1)
constexpr Vector &append(bool); (2)
constexpr Vector &pop(); (3)
| 1 | Adds a single element to the end of the bit-vector. Element will default to 0 unless one == true. |
| 2 | This is a synonym for push() and adds a single bool to the end of the bit-vector.
There are several other append methods so the synonym seems natural. |
| 3 | Removes the last element from the bit-vector & shrinks it if possible. Does nothing if the bit-vector is empty. |
These methods both return a reference to *this so can be chained with other calls.
Example
#include <GF2/GF2.h>
int main()
{
GF2::Vector<> v;
v.push(true); (1)
std::cout << "v: " << v << '\n';
v.push(); (2)
std::cout << "v: " << v << '\n';
v.pop();
std::cout << "v: " << v << '\n';
v.pop();
std::cout << "v: " << v << '\n';
v.pop(); (3)
std::cout << "v: " << v << '\n';
}
| 1 | Adding a 1 element to the end of the bit-vector. |
| 2 | Adding the default element of 0 to the end of the bit-vector. |
| 3 | Calling pop() on an empty bit-vector does nothing. |
Output
v: 1
v: 10
v: 1
v:
v: (1)
| 1 | Calling pop() on an empty vector does nothing. |