-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
executable file
·60 lines (53 loc) · 1.63 KB
/
test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* This is just a toy example to showcase the use of GeSuTr library.
*
* Copyright (C) 2019 Thanasis Vergoulis
*
* This file is part of GeSuTr.
*
* GeSuTr is a free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GeSuTr is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Contact email: [email protected]
*/
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include "ST.h"
using namespace std;
int main(int argc, char* argv[])
{
string* strs = new string[2];
strs[0] = "banana$";
strs[1] = "moana$";
//create the generalised suffix tree
ST* my_tree;
my_tree = new ST(strs,2);
//use the generalised suffix tree to find exact occurrences (matches) of a string
vector<OccPos*> str_occs;
my_tree->findStr("ana",str_occs);
//print the results
cout<<endl;
cout<<"Found "<<str_occs.size()<<" matches."<<endl;
vector<OccPos*>::iterator cur_occ;
cur_occ = str_occs.begin();
while(cur_occ!=str_occs.end())
{
cout<<"(str_id: "<<(*cur_occ)->_str_id<<", pos: "<<(*cur_occ)->_occ_pos<<")"<<endl;
cur_occ++;
}
//test occ counters for each node (if needed)
my_tree->updNodeCnts();
return 0;
}