|
Ponca
82fc77e8c6294111c6f00670e92ec58a24e2ecf2
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 |
| BitSet< N, T >::iterator Ponca::BitSet< N, T >::begin | ( | ) |
Definition at line 15 of file bitset.hpp.
| void Ponca::BitSet< N, T >::clear | ( | ) |
Sets all the bits to EMPTY.
Definition at line 31 of file bitset.hpp.
| bool Ponca::BitSet< N, T >::contains | ( | int | value | ) | const |
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 65 of file bitset.hpp.
| BitSet< N, T >::iterator Ponca::BitSet< N, T >::end | ( | ) |
Definition at line 22 of file bitset.hpp.
| bool Ponca::BitSet< N, T >::erase | ( | int | value | ) |
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 38 of file bitset.hpp.
| void Ponca::BitSet< N, T >::flip | ( | int | i | ) |
| 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 52 of file bitset.hpp.
|
protected |