-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathmymap32.h
More file actions
121 lines (99 loc) · 2.15 KB
/
Copy pathmymap32.h
File metadata and controls
121 lines (99 loc) · 2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef __MYMAP32_H__
#define __MYMAP32_H__
#include "mylist.h"
#include "pthread_mutex.hpp"
#include "log.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MAX_NAME 1024
#define MAX_OBJ_NAME 100
//24 bytes
class Node
{
public:
list_head link;
list_head hash;
intptr_t key;
intptr_t val;
/*
Node(){
key = 0;
val = 0;
}
~Node();
public:
*/
};
//88 bytes
class StrNode
{
public:
list_head link;
list_head hash;
char* key;
intptr_t val;
intptr_t len;
/*
StrNode(){
val = 0;
len = 0;
memset( key, 0, MAX_NAME );
}
~StrNode();
public:
*/
};
class MyMap32
{
public:
MyMap32();
~MyMap32();
void init( int hash_size, int max_size, const char* _obj_name );
bool find( intptr_t key, intptr_t& val );
bool set( intptr_t key, intptr_t val );
bool del( intptr_t key );
void clean();
bool isempty();
int count();
public:
Node* first();
Node* next( Node* pre );
public:
int num;
int hash_size;
int pow2;
int max_size;
char obj_name[MAX_OBJ_NAME];
list_head* hash_table;
list_head link;
list_head free_list;
Node* mem;
};
class MyMapStr
{
public:
MyMapStr();
~MyMapStr();
void init( int hash_size, int max_size, const char* _obj_name );
bool find( const char* key, intptr_t& val );
bool set( const char* key, intptr_t val );
bool del( const char* key );
void clean();
bool isempty();
int count();
public:
StrNode* first();
StrNode* next( StrNode* pre );
public:
int num;
int hash_size;
int pow2;
int max_size;
char obj_name[MAX_OBJ_NAME];
list_head* hash_table;
list_head link;
list_head free_list;
StrNode* mem;
};
#endif