|
Ponca
911e152b8d5ac5c934a260b3832f7f62800b65b9
Point Cloud Analysis library
|
A simple BitSet implementation that mimics a set of indices. More...
#include <bitset.h>
Collaboration diagram for Ponca::BitSet< N, T >:Public Member Functions | |
| void | flip (int i) |
| Toggles the value of a bit. | |
| bool | erase (int value) |
| Tries to insert a value in the set. | |
| bool | insert (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 | clear () |
| Sets all the bits to EMPTY. | |
Protected Attributes | |
| T | m_data [ARRAY_SIZE] = {} |
| An array of bytes. | |
Static Protected Attributes | |
| static constexpr size_t | BIT_SIZE = sizeof(T) * 8 |
| static constexpr size_t | ARRAY_SIZE = (N + BIT_SIZE - 1) / BIT_SIZE |
| The number of bits in one element of the array. | |
A simple BitSet implementation that mimics a set of indices.
The internal logic of this bitset is similar to std::bitset, but is compatible with CUDA.
Allows to insert and search in O(1) complexity, but is memory expensive, because we allocate a single bit for each possible indices, to flag if it was inserted or not, which is not ideal for large amount of indices.
The memory use of the BitSet depending on N should be in theory :
| BitSet size | Memory used |
|---|---|
| Bitset<10000> | 1.25 KB |
| Bitset<1e6> | 125 KB |
| Bitset<1e7> | 1.25 MB |
| N | Maximum number of indices |
| T | The data type of the array storing the bits. Default to 'unsigned long long' for 64 bits storage. |
BitSet::erase, BitSet::insert for set-index-like methods | void Ponca::BitSet< N, T >::clear | ( | ) |
Sets all the bits to EMPTY.
Definition at line 14 of file bitset.hpp.
Search if the value was already inserted or not.
| value | The value to search for (search is O(N) because it corresponds to the index in the BitSet) |
Definition at line 45 of file bitset.hpp.
Tries to insert a value in the set.
| value | The value to be removed in the set. Must always be smaller than N, because we are using the values as indices inside the BitSet. |
Definition at line 20 of file bitset.hpp.
Tries to insert a value in the set.
| value | The value to be inserted in the HashSet. Must always be smaller than N, because we are using the values as indices inside the BitSet. |
Definition at line 33 of file bitset.hpp.
|
staticconstexprprotected |
|
staticconstexprprotected |
|
protected |