forked from simongog/sdsl-lite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sa-int-construct-from-file.cpp
44 lines (40 loc) · 1.41 KB
/
sa-int-construct-from-file.cpp
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
40
41
42
#include <iostream>
#include <fstream>
#include <sdsl/suffix_trees.hpp>
using namespace sdsl;
using namespace std;
int main(int argc, char* argv[])
{
if (argc > 1) {
string file = string(argv[1]);
string ofile = file + ".sa";
if (argc > 2) {
ofile = argv[2];
}
int_vector<> sa;
{
int_vector<64> temp;
load_vector_from_file(temp, file, 8);
cout << "input elements = " << temp.size() << endl;
if (temp.size()==0 or temp[temp.size()-1] != 0) {
cout << "Add 0 to input `" << file << "`" << endl;
temp.resize(temp.size()+1);
temp[temp.size()-1] = 0;
store_to_plain_array<uint64_t>(temp, file);
}
}
qsufsort::construct_sa(sa, file.c_str(), 8);
cout << "done" << endl;
cout << "sa.size()="<<sa.size() << endl;
cout << "sa.width()=" <<(int)sa.width() << endl;
cout << "bit_compress..." << endl;
util::bit_compress(sa);
cout << "sa.width()=" <<(int)sa.width() << endl;
store_to_file(sa, ofile);
} else {
cout << "Usage: " << argv[0] << " file [ofile]" << endl;
cout << " Computes the SA from an array of 64-bit integers." << endl;
cout << " Result is stored in `ofile`, or `file`.sa if `ofile`" << endl;
cout << " is not specified." << endl;
}
}