-
Notifications
You must be signed in to change notification settings - Fork 5
/
hashfunc.hh
67 lines (55 loc) · 2.23 KB
/
hashfunc.hh
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
//*****************************************************************/
//
// Copyright (C) 2006-2009 Seung-Jin Sul
// Department of Computer Science
// Texas A&M University
// Contact: [email protected]
//
// CLASS DEFINITION
// CHashFunc: Universal hash functions
//
// 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
// of the License, or (at your option) any later version.
//
// This program 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 (www.gnu.org).
//
//*****************************************************************/
#ifndef HASHFUNC_HH
#define HASHFUNC_HH
#include <iostream>
#include <fstream>
#include "randomc.h" // MT random number generator
#include <stdint.h>
#include <cstdlib>
typedef struct {
unsigned long long hv1;
unsigned long long hv2;
} HV_STRUCT_T;
class CHashFunc {
unsigned long long _m1; // prime number1 for hash function1
unsigned long long _m2; // prime number1 for hash function2
unsigned int _t; // number of trees
unsigned int _n; // number of taxa
unsigned long long * _a1; // random numbers for hash function1
unsigned long long * _a2; // random numbers for hash function2
unsigned int _c; // double collision factor: constant for c*t*n of hash function2;
public:
CHashFunc() : _m1(0), _m2(0), _t(0), _n(0), _a1(NULL), _a2(NULL), _c(0) {}
CHashFunc(unsigned int t, unsigned int n, unsigned int c);
~CHashFunc();
void UHashfunc_init(unsigned int t, unsigned int n, unsigned int c);
void UHashfunc_init(unsigned int t, unsigned int n, unsigned int c, int32 newseed);
void UHashFunc(HV_STRUCT_T &hv, uint64_t bs64, unsigned numBits);
unsigned long long GetPrime(unsigned long long topNum, unsigned from);
// Implicit bp
unsigned long long getA1(unsigned idx) { return (_a1[idx]); }
unsigned long long getA2(unsigned idx) { return (_a2[idx]); }
unsigned long long getM1() { return _m1; }
unsigned long long getM2() { return _m2; }
};
#endif