10#include "../defines.h"
13#include "./iteratorUtils.h"
14#include "../../Common/Assert.h"
42 template <
int N,
typename T =
unsigned long long>
43 requires ValidCapacity<N>
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);
67 PONCA_MULTIARCH
bool erase(
int value);
81 PONCA_MULTIARCH std::pair<iterator, bool>
insert(
const int& value);
88 PONCA_MULTIARCH [[nodiscard]]
bool contains(
int value)
const;
91 PONCA_MULTIARCH
void clear();
93 PONCA_MULTIARCH [[nodiscard]] iterator begin();
95 PONCA_MULTIARCH [[nodiscard]] iterator end();
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.
container_type m_data
An array of bytes.
void clear()
Sets all the bits to EMPTY.
void flip(int i)
Toggles the value of a bit.
bool contains(int value) const
Search if the value was already inserted or not.
bool erase(int value)
Tries to insert a value in the set.
This Source Code Form is subject to the terms of the Mozilla Public License, v.