-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchashtable.h
64 lines (48 loc) · 1.38 KB
/
chashtable.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
#ifndef _CHASH_
#define _CHASH_
//using namespace std;
//using namespace __gnu_cxx
#define HASHNS __gnu_cxx
#include <list>
//#include <map.h>
#include <ext/hash_map>
//#include <unordered_map>
#include <vector>
#include <iostream>
class cHashItem{
private:
vector<int> iset;
int sup;
int hval;
public:
cHashItem(vector<int> &iary, int lit, int isup, int ihval);
int hashval() { return hval;}
int support() { return sup; }
vector<int> &itemset() { return iset; }
bool subset (cHashItem *ia);
static int compare (cHashItem *ia, cHashItem *ib);
friend ostream& operator << (ostream& fout, cHashItem& lst);
};
#define HASHSIZE 100
struct cHash
{
size_t operator() (int x) const { return (x%HASHSIZE); }
};
//typedef map<int, list<cHashItem *> *, less<int> > cHTable;
//typedef hash_map<int, list<cHashItem *> *, cHash, equal_to<int> > cHTable;
typedef HASHNS::hash_multimap<int, cHashItem *,
HASHNS::hash<int>, equal_to<int> > cHTable;
typedef pair<cHTable::iterator, cHTable::iterator> cHTFind;
typedef cHTable::value_type cHTPair;
class cHashTable{
public:
cHTable chtable;
cHashTable(int sz=HASHSIZE): chtable(sz){}
bool add(vector<int> &iset, int lit, int isup, int ihval);
bool list_add(cHashItem *Hitem);
void print_hashstats(){
cout << "HASHSTATS " << chtable.size() << " "
<< chtable.bucket_count() << endl;
}
};
#endif