-
Notifications
You must be signed in to change notification settings - Fork 0
/
dict_pp.c
executable file
·133 lines (108 loc) · 2.36 KB
/
dict_pp.c
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
125
126
127
128
129
130
131
132
133
#include <dict/dict_pp.h>
#include <stdio.h>
#define DICT_KEY_TYPE void*
#define DICT_VALUE_TYPE void*
#include <dict.h>
static int dict_key_allocator_pp(void* key, void** key_dup)
{
*key_dup = key;
return 0;
}
static int dict_value_allocator_pp(void* value, void** value_dup)
{
*value_dup = value;
return 0;
}
static int dict_key_deallocator_pp(void* key)
{
return 0;
}
static int dict_value_deallocator_pp(void* value)
{
return 0;
}
static int dict_key_comparator_pp(void* key_1, void* key_2)
{
if (key_1 > key_2)
return 1;
else if (key_1 < key_2)
return -1;
else
return 0;
}
static void dict_key_printor_pp(void* key)
{
printf("<%p>", key);
}
static void dict_value_printor_pp(void* value)
{
printf("<%p>", value);
}
dict_context_pp_t* dict_new_pp(void)
{
return dict_new_length_pp(DICT_LENGTH_DEFAULT);
}
dict_context_pp_t* dict_new_length_pp(size_t length)
{
return dict_new(length,
dict_key_allocator_pp, dict_value_allocator_pp,
dict_key_deallocator_pp, dict_value_deallocator_pp,
dict_key_comparator_pp,
dict_key_printor_pp, dict_value_printor_pp);
}
void dict_delete_pp(dict_context_pp_t* context)
{
dict_delete(context);
}
dict_context_pp_t* dict_retain_pp(dict_context_pp_t* context)
{
return dict_retain(context);
}
size_t dict_retain_count_pp(dict_context_pp_t* context)
{
return dict_retain_count(context);
}
dict_context_pp_t* dict_copy_pp(dict_context_pp_t* context)
{
return dict_copy(context);
}
int dict_set_pp(dict_context_pp_t* context, void* key, void* value)
{
return dict_set(context, key, value);
}
int dict_get_pp(dict_context_pp_t* context, void* key, void** value)
{
return dict_get(context, key, value);
}
int dict_remove_pp(dict_context_pp_t* context, void* key)
{
return dict_remove(context, key);
}
int dict_clear_pp(dict_context_pp_t* context)
{
return dict_clear(context);
}
int dict_has_key_pp(dict_context_pp_t* context, void* key)
{
return dict_has_key(context, key);
}
size_t dict_count_pp(dict_context_pp_t* context)
{
return dict_count(context);
}
dict_iter_pp_t* dict_iter_new_pp(dict_context_pp_t* context)
{
return dict_iter_new(context);
}
int dict_iter_get_pp(dict_iter_pp_t* iter, void** key, void** value)
{
return dict_iter_get(iter, key, value);
}
void dict_iter_delete_pp(dict_iter_pp_t* iter)
{
dict_iter_delete(iter);
}
void dict_print_pp(dict_context_pp_t* context)
{
dict_print(context);
}