92#ifndef __ADS_BalancedParentheses
93 #define __ADS_BalancedParentheses
108#include <string_view>
128 static constexpr std::size_t
nil = std::size_t( -1 );
166 [[nodiscard]] std::size_t
size(
void )
const;
175 [[nodiscard]] std::int64_t
excess( std::size_t i )
const;
218 [[nodiscard]] std::size_t
findClose( std::size_t i )
const;
236 std::int64_t d )
const;
254 [[nodiscard]] std::size_t
findOpen( std::size_t j )
const;
271 [[nodiscard]] std::size_t
enclose( std::size_t i )
const;
282 static constexpr std::string_view
persistName =
"BalancedParentheses";
291 static constexpr std::size_t kLeaf = 512;
292 static constexpr std::size_t kGroup = 16;
297 [[nodiscard]] std::size_t scanForward( std::size_t a , std::size_t b ,
299 std::int64_t d )
const;
304 [[nodiscard]] std::size_t scanBackward( std::size_t a , std::size_t b ,
306 std::int64_t d )
const;
310 [[nodiscard]] std::size_t backwardSearch( std::size_t i ,
311 std::int64_t d )
const;
314 [[nodiscard]] std::size_t leafEnd( std::size_t l )
const {
315 return( std::min(
size() , ( l + 1 ) * kLeaf ) );
319 [[nodiscard]]
bool balanced(
void )
const;
322 std::size_t f_nleaf = 0;
323 std::size_t f_groups = 1;
326 std::vector< std::int16_t > f_lexc , f_lmin;
328 std::vector< std::int64_t > f_exc , f_min;
340#include "ADS/succinct/impl/BalancedParentheses.tpp"
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
Rank and select on a static vector of bits of bits in 3.125% of bits more for the rank and less th...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
BalancedParentheses(void)
the empty sequence
std::size_t treeBits(void) const
the bits of the range min-max tree
BalancedParentheses(BitVector b)
the parentheses , 1 for an open one and 0 for a closed one, and the range min-max tree on them
std::int64_t excess(std::size_t i) const
, the open parentheses minus the closed ones in , as
bool operator[](std::size_t i) const
whether the place has an open parenthesis
std::size_t findClose(std::size_t i) const
the closed parenthesis of the open one at
std::size_t forwardSearch(std::size_t i, std::int64_t d) const
the first with , nil if none: the end of a run of parentheses that goes levels below the one at ,...
std::size_t enclose(std::size_t i) const
the open parenthesis of the pair that encloses the open one at , nil if none
std::size_t size(void) const
the number of parentheses
static constexpr std::size_t nil
no place
Definition BalancedParentheses.h:128
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
const CompactRankSelect & bits(void) const
the parentheses with their rank and select
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition BalancedParentheses.h:282
std::size_t findOpen(std::size_t j) const
the open parenthesis of the closed one at
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
a static vector of bits with rank and select in 3.125% of its bits more for the rank and less than 0....
Definition CompactRankSelect.h:118