forked from chad3814/node-hashtable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashtable.h
More file actions
67 lines (49 loc) · 1.56 KB
/
hashtable.h
File metadata and controls
67 lines (49 loc) · 1.56 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
63
64
65
66
67
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include <string>
#include <iostream>
#ifdef __APPLE__
#include <tr1/unordered_map>
#define unordered_map std::tr1::unordered_map
#else
#include <unordered_map>
#define unordered_map std::unordered_map
#endif
#include <node.h>
#include <nan.h>
#include "v8_value_hasher.h"
typedef unordered_map<CopyablePersistent *, CopyablePersistent *, v8_value_hash, v8_value_equal_to> MapType;
class HashTable : public Nan::ObjectWrap {
public:
static void init(v8::Local<v8::Object> target);
private:
HashTable();
HashTable(size_t buckets);
~HashTable();
MapType map;
// new HashTable() or new HashTable(buckets)
static NAN_METHOD(Constructor);
// hashTable.get(key) : value
static NAN_METHOD(Get);
// hashTable.has(key) : boolean
static NAN_METHOD(Has);
// hashTable.put(key, value) : hashtable
static NAN_METHOD(Put);
// hashTable.keys() : []
static NAN_METHOD(Keys);
// hashTable.remove(key) : boolean
static NAN_METHOD(Remove);
// hashTable.clear() : undefined
static NAN_METHOD(Clear);
// hashTable.size() : number of elements
static NAN_METHOD(Size);
// hashTable.rehash(buckets) : undefined
static NAN_METHOD(Rehash);
// hashTable.reserve(size) : undefined
static NAN_METHOD(Reserve);
// hashTable.max_load_factor() or hashTable.max_load_factor(factor) : current or old max_load_factor
static NAN_METHOD(MaxLoadFactor);
// hashTable.forEach(function (key, value) {...}, context) : undefined
static NAN_METHOD(ForEach);
};
#endif