forked from Hongweihuo-Lab/FM-Adaptive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FM.h
73 lines (64 loc) · 2.16 KB
/
FM.h
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
61
62
63
64
65
66
67
68
69
70
71
72
/*============================================
# Filename: FM.h
# Ver 1.0 2014-06-08
# Copyright (C) 2014 ChenLonggang ([email protected])
#
This program is 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 2 or later of the License.
#
# Description:
External class,you can build a hybrid and adaptive fm-index
for a document.and then you can know:
How many times a pattern occs in the document using Counting,
the reference parmater num will holds the times.
All the positions where the pattern occs,and the times.
the reference pointer pos will holds all the places,but
REMEMBER that: prepare and clean the space of pos is your
duty.
Extract a piece of the document using Extracting,the sequence
will hold T[pos...pos+len-1].T denotes the original document.
REMEMBER that: prepare and clean space for sequence is your
duty too.
Save and Load support serialize a FM object to a file or restore
a FM object from a file.
GetN will tell you the size of the file in byte.
SizeInByte will tell you the totle space needed for all operations in byte
SizeInByte_count will tell you sapce only needed for Counting operation
=============================================*/
#ifndef FM_H
#define FM_H
#include"loadkit.h"
#include"savekit.h"
#include"ABS_WT.h"
#include"Huffman_WT.h"
#include"Balance_WT.h"
#include"Hutacker_WT.h"
#include"WT_Handle.h"
class FM
{
public:
FM(const char * filename,int speedlevel=1);
FM();
~FM(){};
FM(const FM & h):wt(h.wt){}
FM& operator =(const FM&h){wt=h.wt;return *this;};
void counting(const char *pattern,int &num);
int * locating(const char *pattern,int & num);
unsigned char * extracting(int pos,int len);
int load(const char * indexfile);
int save(const char * indexfile);
int getN();
int getAlphabetSize();
int sizeInByte();
int sizeInByteForCount();
int sizeInByteForLocate();
int sizeInByteForExtract();
double compressRatio();
double compressRatioForCount();
double compressRatioForLocate();
double compressRatioForExtract();
private:
WT_Handle wt;
};
#endif