File: node_iterator.cpp

package info (click to toggle)
libsdsl 2.1.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,992 kB
  • sloc: cpp: 42,286; makefile: 1,171; ansic: 318; sh: 201; python: 27
file content (39 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <sdsl/suffix_trees.hpp>
#include <iostream>

using namespace sdsl;
using namespace std;

template<class t_cst>
void output_node(const typename t_cst::node_type& v, const t_cst& cst)
{
    cout << cst.depth(v) << "-[" << cst.lb(v) << ","
         << cst.rb(v) << "]" << endl;
}

template<class t_cst>
void run()
{
    t_cst cst;
    construct_im(cst, "ananas", 1);
    for (auto v : cst) {
        output_node(v, cst);
    }
    cout<<"--"<<endl;
    auto v = cst.select_leaf(2);
    for (auto it = cst.begin(v); it != cst.end(v); ++it) {
        output_node(*it, cst);
    }
    cout<<"--"<<endl;
    v = cst.parent(cst.select_leaf(4));
    for (auto it = cst.begin(v); it != cst.end(v); ++it) {
        output_node(*it, cst);
    }
    cout<<"---"<<endl;
}

int main()
{
    run<cst_sct3<>>();
    run<cst_sada<>>();
}