-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashTable.hpp
55 lines (48 loc) · 1.37 KB
/
hashTable.hpp
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
#ifndef _HASHTABLE_
#define _HASHTABLE_
#include <iostream>
#include <vector>
using std::vector;
#include <utility>
using std::pair;
#include <random>
using std::mt19937;
using std::random_device;
#include <cstring>
template <class T>
class HashTable
{
unsigned int bucketSize;
int numFunct;
int w;
int dimensions;
int maxPoints;
mt19937 generator;
unsigned int M;
T *buckets;
double **sVectors;
unsigned int *mArray;
public:
HashTable();
void initialize(size_t, int, int, int, int);
void printHashTable();
~HashTable();
//hashfunction operations
unsigned int amplifiedHashFunctionPoint(class Point *x);
unsigned int hashFunctionPoint(class Point *x, int functionNo);
int insertPoint(class Point *);
int findPoint(class Point *);
T &getneighbors(class Point *x, unsigned int *amplifiedResult)
{
*amplifiedResult = amplifiedHashFunctionPoint(x);
std::cout << "Point: " << x->getID() << " Bucket: " << *amplifiedResult % bucketSize << std::endl;
return buckets[*amplifiedResult % bucketSize];
}
T getDigit(class Point *x, unsigned int *amplifiedResult)
{
*amplifiedResult = amplifiedHashFunctionPoint(x);
return buckets[*amplifiedResult % bucketSize];
}
};
unsigned int modular_expo(unsigned int base, unsigned int exponent, unsigned int modulus);
#endif