This source file includes following definitions.
- assoc_array_init
1
2
3
4
5
6
7
8
9
10 #ifndef _LINUX_ASSOC_ARRAY_H
11 #define _LINUX_ASSOC_ARRAY_H
12
13 #ifdef CONFIG_ASSOCIATIVE_ARRAY
14
15 #include <linux/types.h>
16
17 #define ASSOC_ARRAY_KEY_CHUNK_SIZE BITS_PER_LONG
18
19
20
21
22 struct assoc_array {
23 struct assoc_array_ptr *root;
24 unsigned long nr_leaves_on_tree;
25 };
26
27
28
29
30 struct assoc_array_ops {
31
32 unsigned long (*get_key_chunk)(const void *index_key, int level);
33
34
35 unsigned long (*get_object_key_chunk)(const void *object, int level);
36
37
38 bool (*compare_object)(const void *object, const void *index_key);
39
40
41
42
43 int (*diff_objects)(const void *object, const void *index_key);
44
45
46 void (*free_object)(void *object);
47 };
48
49
50
51
52 struct assoc_array_edit;
53
54 static inline void assoc_array_init(struct assoc_array *array)
55 {
56 array->root = NULL;
57 array->nr_leaves_on_tree = 0;
58 }
59
60 extern int assoc_array_iterate(const struct assoc_array *array,
61 int (*iterator)(const void *object,
62 void *iterator_data),
63 void *iterator_data);
64 extern void *assoc_array_find(const struct assoc_array *array,
65 const struct assoc_array_ops *ops,
66 const void *index_key);
67 extern void assoc_array_destroy(struct assoc_array *array,
68 const struct assoc_array_ops *ops);
69 extern struct assoc_array_edit *assoc_array_insert(struct assoc_array *array,
70 const struct assoc_array_ops *ops,
71 const void *index_key,
72 void *object);
73 extern void assoc_array_insert_set_object(struct assoc_array_edit *edit,
74 void *object);
75 extern struct assoc_array_edit *assoc_array_delete(struct assoc_array *array,
76 const struct assoc_array_ops *ops,
77 const void *index_key);
78 extern struct assoc_array_edit *assoc_array_clear(struct assoc_array *array,
79 const struct assoc_array_ops *ops);
80 extern void assoc_array_apply_edit(struct assoc_array_edit *edit);
81 extern void assoc_array_cancel_edit(struct assoc_array_edit *edit);
82 extern int assoc_array_gc(struct assoc_array *array,
83 const struct assoc_array_ops *ops,
84 bool (*iterator)(void *object, void *iterator_data),
85 void *iterator_data);
86
87 #endif
88 #endif