-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHDGen.cpp
More file actions
30 lines (27 loc) · 803 Bytes
/
HDGen.cpp
File metadata and controls
30 lines (27 loc) · 803 Bytes
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
#include "HDGen.h"
HDGen::HDGen(size_t stp, size_t in_pos, size_t chunk_size, unsigned int alen,
std::vector<git_oid> &hash_list) {
step = stp;
outer_pos = in_pos;
inner_pos = outer_pos + 1;
chunk_len = chunk_size;
hl = hash_list;
abbrv_len = alen;
endpos = hl.size();
}
bool HDGen::get_chunk(std::vector<unsigned char> &buf) {
size_t k = 0;
while (outer_pos < endpos - 1) {
while (inner_pos < endpos) {
unsigned char hd = hamming_distance(hl.at(outer_pos), hl.at(inner_pos), abbrv_len);
buf.push_back(hd);
k++;
inner_pos++;
if (k == chunk_len)
return true;
}
outer_pos = outer_pos + step;
inner_pos = outer_pos + 1;
}
return false;
}