-
Notifications
You must be signed in to change notification settings - Fork 2
/
patricia.h
36 lines (31 loc) · 919 Bytes
/
patricia.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
/*
* patricia.h
* Patricia trie implementation.
*/
#ifndef _PATRICIA_H_
#define _PATRICIA_H_
/*
* Patricia tree mask.
* Each node in the tree can contain multiple masks, so this
* structure is where the mask and data are kept.
*/
struct ptree_mask {
unsigned long pm_mask;
void *pm_data;
};
/*
* Patricia tree node.
*/
struct ptree {
unsigned long p_key; /* Node key */
struct ptree_mask *p_m; /* Node masks */
unsigned char p_mlen; /* Number of masks */
char p_b; /* Bit to check */
struct ptree *p_left; /* Left pointer */
struct ptree *p_right; /* Right pointer */
};
extern struct ptree *pat_insert(struct ptree *n, struct ptree *head);
extern int pat_remove(struct ptree *n, struct ptree *head);
extern struct ptree *pat_search(unsigned long key, struct ptree *head);
extern int pat_count(struct ptree *t, int b);
#endif /* _PATRICIA_H_ */