SDSL: Succinct Data Structure Library
A C++ template library for succinct data structures
 All Classes Namespaces Files Functions Variables Typedefs Friends
Public Types | Public Member Functions | Public Attributes
sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport > Class Template Reference

A class that provides support for bit_vectors that represent a balanced parentheses sequence. Implementation was proposed by Geary et al. (CPM 2004) and extended by Ohlebusch and Gog (SPIRE 2009). More...

#include <bp_support_g.hpp>

List of all members.

Public Types

typedef bit_vector::size_type size_type

Public Member Functions

 bp_support_g (const bit_vector *bp=NULL, uint32_t used_block_size=840)
 Constructor.
 bp_support_g (const bp_support_g &bp_support)
 Copy constructor.
bp_support_goperator= (const bp_support_g &bp_support)
 Assignment operator.
void swap (bp_support_g &bp_support)
void set_vector (const bit_vector *bp)
size_type excess (size_type i) const
size_type rank (size_type i) const
size_type select (size_type i) const
size_type find_close (size_type i) const
size_type find_open (size_type i) const
 Calculate the matching opening parenthesis to the closing parenthesis at position i.
size_type find_open_in_pioneers (size_type i) const
size_type enclose (size_type i) const
 Calculate the index of the opening parenthesis corresponding to the closest matching parenthesis pair enclosing i.
size_type rr_enclose (const size_type i, const size_type j) const
 The range restricted enclose operation.
size_type rmq_open (const size_type l, const size_type r) const
size_type rr_enclose_naive (size_type i, size_type j) const
 The range restricted enclose operation.
size_type rmq (size_type l, size_type r) const
 The range minimum query (rmq) returns the index of the parenthesis with minimal excess in the range $[l..r]$.
size_type double_enclose (size_type i, size_type j) const
 The double enclose operation.
size_type preceding_closing_parentheses (size_type i) const
 Return the number of zeros which procede position i in the balanced parentheses sequence.
size_type size () const
size_type serialize (std::ostream &out, structure_tree_node *v=NULL, std::string name="") const
 Serializes the bp_support_g to a stream.
void load (std::istream &in, const bit_vector *bp)
 Load the bp_support_g for a bit_vector v.
std::string get_info () const

Public Attributes

const RankSupport & bp_rank
const SelectSupport & bp_select

Detailed Description

template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
class sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >

A class that provides support for bit_vectors that represent a balanced parentheses sequence. Implementation was proposed by Geary et al. (CPM 2004) and extended by Ohlebusch and Gog (SPIRE 2009).

This data structure supports the following methods on a bit_vector b that represents a balanced parentheses sequence:

An opening parenthesis in the balanced parentheses sequence is represented by a 1 in the bit_vector and a closing parenthesis by a 0.

This class could be parametrized by four parameters:


Member Function Documentation

template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::double_enclose ( size_type  i,
size_type  j 
) const [inline]

The double enclose operation.

Parameters:
iIndex of an opening parenthesis.
jIndex of an opening parenthesis $ i<j \wedge findclose(i) < j $.
Returns:
The maximal opening parenthesis, say k, such that $ k<j \wedge k>findclose(j) $. If such a k does not exists, double_enclose(i,j) returns size().
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::enclose ( size_type  i) const [inline]

Calculate the index of the opening parenthesis corresponding to the closest matching parenthesis pair enclosing i.

Parameters:
iIndex of an opening parenthesis.
Returns:
The index of the opening parenthesis corresponding to the closest matching parenthesis pair enclosing i, or size() if no such pair exists.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::excess ( size_type  i) const [inline]

Calculates the excess value at index i.

Parameters:
iThe index of which the excess value should be calculated.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::find_close ( size_type  i) const [inline]

Calculate the index of the matching closing parenthesis to the parenthesis at index i.

Parameters:
iIndex of an parenthesis. 0 <= i < size().
Returns:
* i, if the parenthesis at index i is closing,
  • the position j of the matching closing parenthesis, if a matching parenthesis exists,
  • size() if no matching closing parenthesis exists.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::find_open ( size_type  i) const [inline]

Calculate the matching opening parenthesis to the closing parenthesis at position i.

Parameters:
iIndex of a closing parenthesis.
Returns:
* i, if the parenthesis at index i is closing,
  • the position j of the matching opening parenthesis, if a matching parenthesis exists,
  • size() if no matching closing parenthesis exists.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
void sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::load ( std::istream &  in,
const bit_vector bp 
) [inline]

Load the bp_support_g for a bit_vector v.

Parameters:
inThe instream from which the data strucutre is read.
bpBit vector representing a balanced parentheses sequence that is supported by this data structure.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::preceding_closing_parentheses ( size_type  i) const [inline]

Return the number of zeros which procede position i in the balanced parentheses sequence.

Parameters:
iIndex of an parenthesis.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::rank ( size_type  i) const [inline]

Returns the number of opening parentheses up to and including index i.

Precondition:
{ $ 0\leq i < size() $ }
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::rmq ( size_type  l,
size_type  r 
) const [inline]

The range minimum query (rmq) returns the index of the parenthesis with minimal excess in the range $[l..r]$.

Parameters:
lThe left border of the interval $[l..r]$ ( $l\leq r$).
rThe right border of the interval $[l..r]$ ( $l \leq r$).
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::rmq_open ( const size_type  l,
const size_type  r 
) const [inline]

Search the interval [l,r-1] for an opening parenthesis, say i, such that find_close(i) >= r.

Parameters:
lThe left end (inclusive) of the interval to search for the result.
rThe right end (exclusive) of the interval to search for the result.
Returns:
the minimal opening parenthesis i with $ \ell \leq i < r $ and $ find_close(i) \geq r $; if no such i exists size() is returned. The algorithm consists of 4 steps:
  1. scan back from position r to the begin of that block
  2. recursivly scan back the pioneers of the blocks which lie inbetween the blocks of l and r
  3. scan from position l to the end of the block, which contains l
  4. check if there exists a valid solution and return
Time complexity
$ \Order{block\_size} $
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::rr_enclose ( const size_type  i,
const size_type  j 
) const [inline]

The range restricted enclose operation.

Parameters:
iIndex of an opening parenthesis.
jIndex of an opening parenthesis/ $ i<j \wedge findclose(i) < j $.
Returns:
The smallest index, say k, of an opening parenthesis such that findclose(i) < k < j and findclose(j) < findclose(k). If such a k does not exists, restricted_enclose(i,j) returns size().
Time complexity
$ \Order{block\_size} $
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::rr_enclose_naive ( size_type  i,
size_type  j 
) const [inline]

The range restricted enclose operation.

Parameters:
iIndex of an opening parenthesis.
jIndex of an opening parenthesis/ $ i<j \wedge findclose(i) < j $.
Returns:
The smallest index, say k, of an opening parenthesis such that findclose(i) < k < j and findclose(j) < findclose(k). If such a k does not exists, restricted_enclose(i,j) returns size().
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::select ( size_type  i) const [inline]

Returns the index of the i-th opening parenthesis.

Parameters:
iNumber of the parenthesis to select.
Precondition:
{ $1\leq i < rank(size())$ }
Postcondition:
{ $ 0\leq select(i) < size() $ }
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::serialize ( std::ostream &  out,
structure_tree_node v = NULL,
std::string  name = "" 
) const [inline]

Serializes the bp_support_g to a stream.

Parameters:
outThe outstream to which the data structure is written.
Returns:
The number of bytes written to out.
template<class NearestNeighbourDictionary = nearest_neighbour_dictionary<30>, class RankSupport = rank_support_v<>, class SelectSupport = select_support_mcl<>, class RangeMaxSupport = range_maximum_support_sparse_table<int_vector<> >::type>
size_type sdsl::bp_support_g< NearestNeighbourDictionary, RankSupport, SelectSupport, RangeMaxSupport >::size ( ) const [inline]

The size of the supported balanced parentheses sequence.

Returns:
the size of the supported balanced parentheses sequence.

The documentation for this class was generated from the following file: