10#include "../defines.h"
13#include "./iteratorUtils.h"
14#include "../../Common/Assert.h"
41 template <
int N,
typename T =
unsigned long long>
44 static_assert(
N > 0,
"The capacity must be strictly positive");
47 static constexpr size_t BIT_SIZE =
sizeof(T) * 8;
48 static constexpr size_t ARRAY_SIZE = (
N + BIT_SIZE - 1) / BIT_SIZE;
50 using container_type = std::array<T, N>;
51 using iterator =
typename container_type::iterator;
54 PONCA_MULTIARCH
BitSet() =
default;
59 PONCA_MULTIARCH
void flip(
int i);
81 PONCA_MULTIARCH std::pair<iterator, bool>
insert(
const int&
value);
91 PONCA_MULTIARCH
void clear();
93 PONCA_MULTIARCH [[
nodiscard]] iterator begin();
95 PONCA_MULTIARCH [[
nodiscard]] iterator end();
Aggregator class used to declare specialized structures using CRTP.
A simple BitSet implementation that mimics a set of indices.
std::pair< iterator, bool > insert(const int &value)
Tries to insert a value in the set.
void clear()
Sets all the bits to EMPTY.
container_type m_data
An array of bytes.
void flip(int i)
Toggles the value of a bit.
bool erase(int value)
Tries to insert a value in the set.
bool contains(int value) const
Search if the value was already inserted or not.
This Source Code Form is subject to the terms of the Mozilla Public License, v.