forked from petervaro/cutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcshm.h
124 lines (117 loc) · 5.88 KB
/
cshm.h
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
121
122
123
124
/* INFO ************************************************************************
** **
** cutils **
** ====== **
** **
** Modern and Lightweight C Utilities **
** Version: 0.8.96.288 (20141027) **
** **
** File: cshm.h **
** **
** For more information about the project, visit <http://www.cutils.org>. **
** Copyright (C) 2014 Peter Varo **
** **
** This program is free software: you can redistribute it and/or modify it **
** under the terms of the GNU General Public License as published by the **
** Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, but **
** WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **
** See the GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program, most likely a file in the root directory, **
** called 'LICENSE'. If not, see <http://www.gnu.org/licenses>. **
** **
************************************************************************ INFO */
/* !!! DON NOT ADD GUARD TO THIS FILE !!! */
#ifndef _C_STATIC_HASH_MAP_H_18841687438603127_
#define _C_STATIC_HASH_MAP_H_18841687438603127_
#define FILE_STARTS_HERE
#include <stddef.h> /* size_t */
#include <stdbool.h> /* bool */
/*----------------------------------------------------------------------------*/
/* Shorthands for this source */
#undef _concat_underscore
#undef concat_underscore
#undef HASH_MAP
#undef METHOD
#undef SUPPORT
#undef SUPPORT_METHOD
#define _concat_underscore(token1, token2) token1##_##token2
#define concat_underscore(token1, token2) _concat_underscore(token1, token2)
#define HASH_MAP cutils_cshm_StaticHashMap_void_ptr_and_void_ptr
#define METHOD(func) concat_underscore(HASH_MAP, func)
#define SUPPORT(type) concat_underscore(HASH_MAP, type)
#define SUPPORT_METHOD(type, func) concat_underscore(HASH_MAP, type##_##func)
/*----------------------------------------------------------------------------*/
typedef struct {} HASH_MAP;
typedef struct {} SUPPORT(iterator);
/*----------------------------------------------------------------------------*/
extern bool
METHOD(new)(HASH_MAP **hashmap,
size_t count);
/*----------------------------------------------------------------------------*/
extern void
METHOD(del)(HASH_MAP *hashmap);
/*----------------------------------------------------------------------------*/
extern bool
METHOD(add)(HASH_MAP *hashmap,
bool (*compare)(const void*, const void*, size_t),
int key_size,
size_t value_size,
const void *key,
const void *value);
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
extern bool
METHOD(add_default5)(HASH_MAP *hashmap,
int key_size,
size_t value_size,
const void *key,
const void *value);
/*----------------------------------------------------------------------------*/
extern void *
METHOD(get)(HASH_MAP *hashmap,
bool (*compare)(const void*, const void*, size_t),
size_t key_size,
const void *key);
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
extern void *
METHOD(get_default3)(HASH_MAP *hashmap,
size_t key_size,
const void *key);
/*----------------------------------------------------------------------------*/
extern SUPPORT(iterator) *
METHOD(iter)(HASH_MAP *hashmap);
/*----------------------------------------------------------------------------*/
extern void
SUPPORT_METHOD(iterator, del)(SUPPORT(iterator) *iterator);
/*----------------------------------------------------------------------------*/
extern bool
SUPPORT_METHOD(iterator, next)(SUPPORT(iterator) *iterator,
void *key);
/*----------------------------------------------------------------------------*/
extern bool
SUPPORT_METHOD(iterator, values)(SUPPORT(iterator) *iterator,
void *value);
/*----------------------------------------------------------------------------*/
extern bool
SUPPORT_METHOD(iterator, items)(SUPPORT(iterator) *iterator,
void *key,
void *value);
/*----------------------------------------------------------------------------*/
extern bool
METHOD(compare)(const void *item1,
const void *item2,
size_t item_size);
/*----------------------------------------------------------------------------*/
/* Undefine helper macros */
#undef _concat_underscore
#undef concat_underscore
#undef HASH_MAP
#undef METHOD
#undef SUPPORT
#undef SUPPORT_METHOD
#endif /* _C_STATIC_HASH_MAP_H_18841687438603127_ */