-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhashtable.h
60 lines (48 loc) · 1.25 KB
/
hashtable.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
#ifndef Included_HashTable_H
#define Included_HashTable_H
#include "List.h"
#include "Node.h"
//#include "bankAccount.h"
#include <iostream>
#include <pthread.h>
class bankAccount;
class Bucket
{
public:
List<bankAccount>* bucketList; //lista apo bankAccount
pthread_mutex_t mtx; //kai mutex gia kleidwma
Bucket()
{
bucketList = new List<bankAccount>();
pthread_mutex_init (&mtx, NULL);
}
~Bucket()
{
delete bucketList;
pthread_mutex_destroy(&mtx);
}
};
class HashTable
{
private:
int nBuckets;
int totalSize;
Bucket** buckets;
pthread_mutex_t mtx;
public:
HashTable(int NBuckets);
~HashTable();
int get_size();
int get_nBuckets();
int hashFunction(std::string name);
Node<bankAccount>* get_bucket(std::string name);
void lockHashtable();
void unlockHashtable();
void lockBucketOf(std::string& name);
void unlockBucketOf(std::string& name);
bool insertNode(bankAccount* bAccount);
bankAccount* searchNode(std::string name);
//bool deleteNode(std::string name);
//void printSizeOfBuckets();
};
#endif