File: use-a-wavelet-tree.cpp

package info (click to toggle)
libsdsl 2.1.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,980 kB
  • sloc: cpp: 42,286; makefile: 1,171; ansic: 318; sh: 201; python: 27
file content (27 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (16)
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
#include <sdsl/wavelet_trees.hpp>
#include <iostream>

using namespace sdsl;
using namespace std;

int main(int argc, char* argv[])
{
    if (argc < 2) {
        cout << "Usage: " << argv[0] << " file" << endl;
        return 1;
    }
    wt_huff<rrr_vector<63>> wt;
    construct(wt, argv[1], 1);

    cout << "wt.size()="<< wt.size() << endl;
    cout << "wt.sigma ="<< wt.sigma << endl;
    if (wt.size() > 0) {
        // access an element
        cout << "wt[0]=" << wt[0] << endl;
        // rank an element (exclude)
        uint64_t r = wt.rank(wt.size(), wt[0]);
        cout << "wt.rank(wt.size(), wt[0])=" << r  << endl;
        // select element ()
        cout << "wt.select(r, wt[0]) = " << wt.select(r, wt[0]) << endl;
    }
}