Repository navigation
Expand file tree
/
Copy pathhashtable.h
More file actions
56 lines (40 loc) · 1.51 KB
/
Copy pathhashtable.h
File metadata and controls
56 lines (40 loc) · 1.51 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
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include <node.h>
#ifdef __APPLE__
#include <tr1/unordered_map>
typedef std::tr1::unordered_map<std::string,v8::Persistent<v8::Value> > unordered_map;
#else
#include <unordered_map>
typedef std::unordered_map<std::string,v8::Persistent<v8::Value>> unordered_map;
#endif
class HashTable : public node::ObjectWrap {
public:
static void init(v8::Handle<v8::Object> exports);
private:
HashTable();
HashTable(size_t buckets);
~HashTable();
unordered_map map;
//new HashTable() or new HashTable(buckets)
static v8::Handle<v8::Value> Constructor(const v8::Arguments &args);
//hashTable.get(key) : value
static v8::Handle<v8::Value> Get(const v8::Arguments &args);
//hashTable.put(key, value)
static v8::Handle<v8::Value> Put(const v8::Arguments &args);
//hashTable.keys() : []
static v8::Handle<v8::Value> Keys(const v8::Arguments &args);
//hashTable.remove(key)
static v8::Handle<v8::Value> Remove(const v8::Arguments &args);
//hashTable.clear()
static v8::Handle<v8::Value> Clear(const v8::Arguments &args);
//hashTable.size() : number of elements
static v8::Handle<v8::Value> Size(const v8::Arguments &args);
//hashTable.rehash(buckets)
static v8::Handle<v8::Value> Rehash(const v8::Arguments &args);
//hashTable.reserve(size)
static v8::Handle<v8::Value> Reserve(const v8::Arguments &args);
//hashTable.max_load_factor() or hashTable.max_load_factor(factor)
static v8::Handle<v8::Value> MaxLoadFactor(const v8::Arguments &args);
};
#endif