13 template <
int N,
typename T>
14 typename BitSet<N, T>::iterator BitSet<N, T>::begin()
16 return m_data.begin();
19 template <
int N,
typename T>
20 typename BitSet<N, T>::iterator BitSet<N, T>::end()
22 return m_data.begin() + N;
27 template <
int N,
typename T>
33 template <
int N,
typename T>
36 PONCA_ASSERT_MSG(value >= 0 && value < N,
37 "Attempted to remove a value that is outside the scope of the BitSet");
38 const int byte = value / BIT_SIZE;
39 const int bit = value % BIT_SIZE;
40 const T bitMask = (T(1) << bit);
41 const bool alreadyEmpty = (m_data[byte] & bitMask) != 0;
42 m_data[byte] &= ~bitMask;
46 template <
int N,
typename T>
49 PONCA_ASSERT_MSG(value >= 0 && value < N,
"Inserted value is outside the scope of the BitSet");
50 const int byte = value / BIT_SIZE;
51 const int bit = value % BIT_SIZE;
52 const T bitMask = (T(1) << bit);
53 const bool alreadyInserted = (m_data[byte] & bitMask) == 0;
54 m_data[byte] |= bitMask;
55 return std::make_pair(m_data.begin() +
byte, alreadyInserted);
58 template <
int N,
typename T>
61 PONCA_ASSERT_MSG(value >= 0 && value < N,
"Searched value is outside the scope of the BitSet");
62 const int byte = value / BIT_SIZE;
63 const int bit = value % BIT_SIZE;
64 return (m_data[
byte] & (T(1) << bit)) != 0;
70 template <
int N,
typename T>
73 PONCA_ASSERT_MSG(i >= 0 && i < N,
"Flipped value is outside the scope of the BitSet");
74 const int byte = i / BIT_SIZE;
75 const int bit = i % BIT_SIZE;
76 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 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.
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.