13 template <
int N,
typename T>
14 requires ValidCapacity<N>
15 typename BitSet<N, T>::iterator BitSet<N, T>::begin()
17 return m_data.begin();
20 template <
int N,
typename T>
21 requires ValidCapacity<N>
22 typename BitSet<N, T>::iterator BitSet<N, T>::end()
24 return m_data.begin() + N;
29 template <
int N,
typename T>
30 requires ValidCapacity<N>
36 template <
int N,
typename T>
40 PONCA_ASSERT_MSG(value >= 0 && value < N,
41 "Attempted to remove a value that is outside the scope of the BitSet");
42 const int byte = value / BIT_SIZE;
43 const int bit = value % BIT_SIZE;
44 const T bitMask = (T(1) << bit);
45 const bool alreadyEmpty = (m_data[byte] & bitMask) != 0;
46 m_data[byte] &= ~bitMask;
50 template <
int N,
typename T>
54 PONCA_ASSERT_MSG(value >= 0 && value < N,
"Inserted value is outside the scope of the BitSet");
55 const int byte = value / BIT_SIZE;
56 const int bit = value % BIT_SIZE;
57 const T bitMask = (T(1) << bit);
58 const bool alreadyInserted = (m_data[byte] & bitMask) == 0;
59 m_data[byte] |= bitMask;
60 return std::make_pair(m_data.begin() +
byte, alreadyInserted);
63 template <
int N,
typename T>
67 PONCA_ASSERT_MSG(value >= 0 && value < N,
"Searched value is outside the scope of the BitSet");
68 const int byte = value / BIT_SIZE;
69 const int bit = value % BIT_SIZE;
70 return (m_data[
byte] & (T(1) << bit)) != 0;
76 template <
int N,
typename T>
80 PONCA_ASSERT_MSG(i >= 0 && i < N,
"Flipped value is outside the scope of the BitSet");
81 const int byte = i / BIT_SIZE;
82 const int bit = i % BIT_SIZE;
83 m_data[byte] ^= (T(1) << bit);
std::pair< iterator, bool > insert(const int &value)
Tries to insert a value in the set.
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.
void fill(ForwardIt first, ForwardIt last, const T &value)
Assigns the given value to all elements in the range [first, last).
This Source Code Form is subject to the terms of the Mozilla Public License, v.