-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEntry.cpp
More file actions
57 lines (42 loc) · 1.15 KB
/
Entry.cpp
File metadata and controls
57 lines (42 loc) · 1.15 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
//
// Created by Stathis on 3/12/2019.
//
#include "Entry.h"
#include <limits.h>
#include <cstdio>
#include <cstdlib>
//-------------------- Constructors --------------------
Entry::Entry(int key, int value, bool removeBit) :
key(key), value(value), removeBit(removeBit) {}
Entry::Entry(int key, int value) : Entry(key, value, 0) {}
Entry::Entry() : Entry(0, 0, 0) {}
//-------------------- Getters - Setters --------------------
int Entry::getKey() {
return this->key;
}
int Entry::getValue() {
return this->value;
}
bool Entry::isRemove() {
return this->removeBit;
}
void Entry::updateValue(int newValue) {
this->value = newValue;
}
void Entry::updateRemove(bool newRemoveBit) {
this->removeBit = newRemoveBit;
// if this is a remove, set to sentinal value
if (!newRemoveBit)
return;
this->value = INT_MIN;
}
void Entry::setEntry(Entry *e) {
key = e->getKey();
value = e->getValue();
removeBit = e->isRemove();
// memcpy(this, e, sizeof(Entry));
}
//-------------------- Printer method --------------------
void Entry::printer() {
printf("Entry : [%d, %d, %d ]\n", key, value, removeBit);
}