-
Notifications
You must be signed in to change notification settings - Fork 0
/
TranscodingDiskVector.h
62 lines (45 loc) · 1.36 KB
/
TranscodingDiskVector.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
/* -
* Copyright (c) 2012 Nava Whiteford <[email protected]>
* suffixcore - core suffixtree algorithms
*
* A license to use this software is granted to users given access to the git repository at: https://github.com/sgenomics/suffixcore
* A complete copy of this license is located in the license.txt file of this package.
*
* In Summary this software:
*
* Can be used for creating unlimited applications.
* Can be distributed in binary or object form only.
* Commercial use is allowed.
* Can modify source-code but cannot distribute modifications (derivative works).
*/
#ifndef TRANSCODINGDISKVECTOR
#define TRANSCODINGDISKVECTOR
#include <stdio.h>
#include <stdint.h>
using namespace std;
class TranscodingDiskVector {
public:
TranscodingDiskVector() {}
TranscodingDiskVector(string filename) {
filehandle = fopen(filename.c_str(),"r");
}
uint16_t operator[](uint64_t index) {
uint16_t data1=0;
uint16_t data2=0;
fseek(filehandle,index*sizeof(uint16_t),SEEK_SET);
fread(&data1,sizeof(uint8_t),1,filehandle);
fread(&data2,sizeof(uint8_t),1,filehandle);
uint16_t data;
data = data1 << 8;
data += data2;
return data;
}
void push_back(uint16_t i) {}
size_t size() {
fseek(filehandle,0,SEEK_END);
size_t filesize = ftell(filehandle);
return filesize/sizeof(uint16_t);
}
FILE *filehandle;
};
#endif