3 #ifndef INCLUDE_NN_NLIB_SUCCINCT_BP_H_
4 #define INCLUDE_NN_NLIB_SUCCINCT_BP_H_
6 #include "nn/nlib/Swap.h"
10 #if defined(_MSC_VER) && defined(nx_succinct_EXPORTS)
11 #undef NLIB_VIS_PUBLIC
12 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
24 NLIB_MOVE_MEMBER_HELPER_2(
Bp, m_Bp, m_Select1);
28 swap(m_Select1, rhs.m_Select1);
30 template <
class TREEITER>
42 int Parent(uint32_t pos)
const NLIB_NOEXCEPT {
return this->Enclose(pos); }
49 Set* Get1stLevelSet() NLIB_NOEXCEPT;
50 bool Build() NLIB_NOEXCEPT;
54 detail::SbvSelect m_Select1;
58 template <class TREEITER>
59 bool Bp::Init(TREEITER& iter, uint32_t num_nodes) NLIB_NOEXCEPT {
64 if (num_nodes >= 0x80000000)
return false;
65 if (m_Bp)
return false;
66 Set* bv = Get1stLevelSet();
67 bv->
Init(num_nodes * 2);
72 const void* parent = iter.ParentNodePtr();
73 const void* node = iter.NodePtr();
74 if (stack.
empty() || stack.
back() == parent) {
78 while (stack.
back() != parent) {
85 }
while (iter.MoveNext());
97 NLIB_DEFINE_STD_SWAP(::nlib_ns::succinct::Bp)
99 #if defined(_MSC_VER) && defined(nx_succinct_EXPORTS)
100 #undef NLIB_VIS_PUBLIC
101 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
104 #endif // INCLUDE_NN_NLIB_SUCCINCT_BP_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Defines the basic classes that form the basis to Rank and Select operations.
const uint32_t * GetBitVector() const noexcept
Returns the pointer to the bit vector.
bool push_back(const T &v) noexcept
Adds an element to the vector.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
uint32_t GetBitVectorSize() const noexcept
Returns the size of the bit vector.
~Bp() noexcept
Destructor.
bool TurnOn(uint32_t idx) noexcept
Adds a 32-bit unsigned integer to the set.
T & back()
Gets the last element.
bool pop_back() noexcept
Deletes an element from the end of the vector.
Succinct data structure to hold a set of 32-bit unsigned integers for a Rank/Select operation...
int Parent(uint32_t pos) const noexcept
Returns the position of the parentheses equivalent to the parent node.
Provides a compact tree structure that can provide various operations in constant time...
void swap(Bp &rhs) noexcept
Swaps the contents of an object.
The class for writing binary to streams (to OutputStream).
Bp() noexcept
Instantiates the object.
bool Init(uint32_t bv_size) noexcept
Initializes an object.
The class for reading binary from streams (from InputStream).
bool empty() const noexcept
Determines whether the vector is empty.
The class for realloc-based implementations of vectors with POD-type elements.