-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathODSClient.h
More file actions
62 lines (47 loc) · 1.25 KB
/
ODSClient.h
File metadata and controls
62 lines (47 loc) · 1.25 KB
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
#ifndef ODSCLIENT_H
#define ODSCLIENT_H
#include <unordered_map>
using namespace std;
class ODSClient {
public:
// Used for oblivious priority queue (integer payloads)
unordered_map<int, int> intStorage;
void Start() { }
int AccessReadInt(int id) {
if (intStorage.find(id) != intStorage.end())
return intStorage[id];
return -1;
}
void AccessWriteInt(int id, int key) {
intStorage[id] = key;
}
void AccessInsertInt(int id, int key) {
intStorage[id] = key;
}
void AccessDelInt(int id) {
intStorage.erase(id);
}
void Finalize(int root, int padVal) {
// Stub: reassign positions and add dummy operations as needed.
}
};
// Template client for objects (used by the AVL-based map)
template <typename T>
class ODSClientObj {
public:
unordered_map<int, T> storage;
void Start() { }
T AccessRead(int id) {
return storage[id];
}
void AccessWrite(int id, const T &obj) {
storage[id] = obj;
}
void AccessInsert(int id, const T &obj) {
storage[id] = obj;
}
void Finalize(int root, int padVal) {
// Stub for padding.
}
};
#endif // ODSCLIENT_H