-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashNode.cpp
More file actions
35 lines (27 loc) · 818 Bytes
/
HashNode.cpp
File metadata and controls
35 lines (27 loc) · 818 Bytes
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
#include "HashNode.h"
HashNode::HashNode(MD5 *md5, std::string initName, int nameNum) :
keys_(),
initName_(initName),
nameNum_(nameNum),
md5_(md5),
mappedCount_(0) {
std::string virName;
for (int i = 0; i < nameNum_; i++) {
srandom(i * i);
virName = initName_ + std::to_string(i * random()) + std::to_string(i * random() * random());
md5_->GenerateMD5(virName.c_str(), virName.length());
keys_.push_back(md5_->ToULong32());
}
}
const std::vector<HashNode::KeyType>& HashNode::getNodeKeys() const {
return this->keys_;
}
std::string HashNode::getInitName() const {
return initName_;
}
void HashNode::increaseMappedCount() {
this->mappedCount_++;
}
unsigned long long HashNode::getMappedCount() const {
return this->mappedCount_;
}