ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
LoudsTree.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*---------------------------- File LoudsTree.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
59/*--------------------------------------------------------------------------*/
60/*----------------------------- DEFINITIONS --------------------------------*/
61/*--------------------------------------------------------------------------*/
62
63#ifndef __ADS_LoudsTree
64 #define __ADS_LoudsTree
65/* self-identification: #endif constant */
66
67/*--------------------------------------------------------------------------*/
68/*------------------------------ INCLUDES ----------------------------------*/
69/*--------------------------------------------------------------------------*/
70
71#include "ADS/Contract.h"
74
75#include <cstddef>
76#include <string_view>
77#include <vector>
78
79/*--------------------------------------------------------------------------*/
80/*--------------------------- NAMESPACE ------------------------------------*/
81/*--------------------------------------------------------------------------*/
82
83namespace ADS
84{
85
86/*--------------------------------------------------------------------------*/
87/*---------------------------- CLASS LoudsTree -----------------------------*/
88/*--------------------------------------------------------------------------*/
89
92{
93
94/*--------------------------------------------------------------------------*/
95 public:
96 static constexpr std::size_t nil = std::size_t( -1 );
97
99 LoudsTree( void );
100
121 explicit LoudsTree( const std::vector< std::vector< std::size_t > > & c );
122
125 explicit LoudsTree( BitVector b );
126
128 [[nodiscard]] std::size_t size( void ) const;
129
131 [[nodiscard]] std::size_t root( void ) const;
132
138 [[nodiscard]] std::size_t degree( std::size_t v ) const;
139
144 [[nodiscard]] std::size_t parent( std::size_t v ) const;
145
150 [[nodiscard]] std::size_t leftmostChild( std::size_t v ) const;
151
155 [[nodiscard]] std::size_t rightSibling( std::size_t v ) const;
156
160 [[nodiscard]] std::size_t child( std::size_t v , std::size_t i ) const;
161
164 [[nodiscard]] bool isLeaf( std::size_t v ) const;
165
167 [[nodiscard]] const BitVector & bits( void ) const;
168
169/*----------------------------- THE PERSISTENCE ----------------------------*/
170
172 static constexpr std::string_view persistName = "LoudsTree";
173
176 template< class A >
177 void persist( A & a );
178
179/*--------------------------------------------------------------------------*/
180 private:
183 [[nodiscard]] bool valid( void ) const;
184
185 RankSelect f_b;
186
187 }; // end( class LoudsTree )
188
189/*--------------------------------------------------------------------------*/
190
191} // end( namespace ADS )
192
193/*--------------------------------------------------------------------------*/
194/*-------------------------- IMPLEMENTATION --------------------------------*/
195/*--------------------------------------------------------------------------*/
196
197#include "ADS/succinct/impl/LoudsTree.tpp"
198
199/*--------------------------------------------------------------------------*/
200
201#endif /* LoudsTree.h included */
202
203/*--------------------------------------------------------------------------*/
204/*-------------------------- End File LoudsTree.h --------------------------*/
205/*--------------------------------------------------------------------------*/
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 leftmostChild(std::size_t v) const
the first child of , nil for a leaf, i.e., when a 0 follows the -th 1
LoudsTree(BitVector b)
the tree whose code is
std::size_t child(std::size_t v, std::size_t i) const
the child of , from 0, i.e.,
std::size_t rightSibling(std::size_t v) const
the next sibling of , nil for the last one, i.e., when a 0 follows the 0 of
std::size_t parent(std::size_t v) const
the parent of , nil for the root, i.e., , the 1s before the 0 of less the one of the dummy root
std::size_t size(void) const
the number of nodes
std::size_t degree(std::size_t v) const
the number of children of , the 0s between the -th 1 and the next, i.e., with the ranks counted from...
const BitVector & bits(void) const
, the code
std::size_t root(void) const
the root, nil if the tree is empty
LoudsTree(void)
the empty tree
static constexpr std::size_t nil
no node
Definition LoudsTree.h:96
bool isLeaf(std::size_t v) const
whether has no children
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition LoudsTree.h:172
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
LoudsTree(const std::vector< std::vector< std::size_t > > &c)
the tree whose node has the children , in order, rooted at 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