ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
JacobsonTree.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*--------------------------- File JacobsonTree.h --------------------------*/
3/*--------------------------------------------------------------------------*/
52/*--------------------------------------------------------------------------*/
53/*----------------------------- DEFINITIONS --------------------------------*/
54/*--------------------------------------------------------------------------*/
55
56#ifndef __ADS_JacobsonTree
57 #define __ADS_JacobsonTree
58/* self-identification: #endif constant */
59
60/*--------------------------------------------------------------------------*/
61/*------------------------------ INCLUDES ----------------------------------*/
62/*--------------------------------------------------------------------------*/
63
64#include "ADS/Contract.h"
67
68#include <cstddef>
69#include <string_view>
70#include <utility>
71#include <vector>
72
73/*--------------------------------------------------------------------------*/
74/*--------------------------- NAMESPACE ------------------------------------*/
75/*--------------------------------------------------------------------------*/
76
77namespace ADS
78{
79
80/*--------------------------------------------------------------------------*/
81/*--------------------------- CLASS JacobsonTree ---------------------------*/
82/*--------------------------------------------------------------------------*/
83
86{
87
88/*--------------------------------------------------------------------------*/
89 public:
90 static constexpr std::size_t nil = std::size_t( -1 );
91
93 JacobsonTree( void );
94
116 explicit JacobsonTree(
117 const std::vector< std::pair< std::size_t , std::size_t > > & c );
118
121 explicit JacobsonTree( BitVector b );
122
124 [[nodiscard]] std::size_t size( void ) const;
125
127 [[nodiscard]] std::size_t root( void ) const;
128
142 [[nodiscard]] std::size_t left( std::size_t v ) const;
143
147 [[nodiscard]] std::size_t right( std::size_t v ) const;
148
163 [[nodiscard]] std::size_t parent( std::size_t v ) const;
164
167 [[nodiscard]] bool isLeaf( std::size_t v ) const;
168
170 [[nodiscard]] const BitVector & bits( void ) const;
171
172/*----------------------------- THE PERSISTENCE ----------------------------*/
173
175 static constexpr std::string_view persistName = "JacobsonTree";
176
179 template< class A >
180 void persist( A & a );
181
182/*--------------------------------------------------------------------------*/
183 private:
185 [[nodiscard]] std::size_t nodeAt( std::size_t q ) const;
186
189 [[nodiscard]] bool valid( void ) const;
190
191 RankSelect f_b;
192
193 }; // end( class JacobsonTree )
194
195/*--------------------------------------------------------------------------*/
196
197} // end( namespace ADS )
198
199/*--------------------------------------------------------------------------*/
200/*-------------------------- IMPLEMENTATION --------------------------------*/
201/*--------------------------------------------------------------------------*/
202
203#include "ADS/succinct/impl/JacobsonTree.tpp"
204
205/*--------------------------------------------------------------------------*/
206
207#endif /* JacobsonTree.h included */
208
209/*--------------------------------------------------------------------------*/
210/*------------------------- End File JacobsonTree.h ------------------------*/
211/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Rank and select on a static vector of bits of bits with 1s (chapter 15, Compressed Data Structures...
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
std::size_t size(void) const
the number of nodes
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition JacobsonTree.h:175
static constexpr std::size_t nil
no node
Definition JacobsonTree.h:90
std::size_t parent(std::size_t v) const
the parent of , nil for the root
JacobsonTree(BitVector b)
the tree whose code by levels is
bool isLeaf(std::size_t v) const
whether has no children
std::size_t root(void) const
the root, nil if the tree is empty
const BitVector & bits(void) const
, the code by levels
JacobsonTree(void)
the empty tree
JacobsonTree(const std::vector< std::pair< std::size_t, std::size_t > > &c)
the tree whose node has the children c[ u ].first (left) and c[ u ].second (right),...
std::size_t right(std::size_t v) const
the right child of , nil if missing: left() with the place
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::size_t left(std::size_t v) const
the left child of , nil if missing: the node at the place of , counted from 0
BasicRankSelect< false > RankSelect
the directory with its inventories of select built in the constructor, the fastest select
Definition RankSelect.h:556
Definition ADT.h:96