|
Ponca
4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
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 Types | |
| using | container_type = std::array< T, N > |
| using | iterator = typename container_type::iterator |
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. | |
| std::pair< iterator, bool > | insert (const 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. | |
| iterator | begin () |
| iterator | end () |
Protected Attributes | |
| container_type | m_data = {} |
| An array of bytes. | |
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 | using Ponca::BitSet< N, T >::container_type = std::array<T, N> |
| using Ponca::BitSet< N, T >::iterator = typename container_type::iterator |
Definition at line 14 of file bitset.hpp.
| void Ponca::BitSet< N, T >::clear | ( | ) |
Sets all the bits to EMPTY.
Definition at line 28 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 59 of file bitset.hpp.
Definition at line 20 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 34 of file bitset.hpp.
| std::pair< typename BitSet< N, T >::iterator, bool > Ponca::BitSet< N, T >::insert | ( | const int & | value | ) |
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 47 of file bitset.hpp.