summaryrefslogtreecommitdiff
path: root/lib/set.h
blob: 97f5353631e258fcb9c25a93f4eaca184da79f4e (plain)
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
#ifndef lib_set_h
#define lib_set_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    lib/set.h
 * \brief   Set of ordered data service.
 * \ingroup lib
 *
 * A set is a ordered binary tree structure.
 *
 * It defines the following set of operations efficiently:
 *  - insert an element,
 *  - find an element,
 *  - remove an element,
 *  - travel the set in order.
 */

/* Forward declaration. */
typedef struct set_node_t set_node_t;

/**
 * Set node comparison function pointer.
 * \param  left  left hand node
 * \param  right  right hand node
 * \return  true iff left is lesser than right
 */
typedef bool
(*set_node_less_t) (set_node_t *left, set_node_t *right);

/** Set structure. */
struct set_t
{
    /** Set root node. */
    set_node_t *root;
    /** Set "is lesser than" comparison function. */
    set_node_less_t less;
};
typedef struct set_t set_t;

#include "lib/aatree.h"

#endif /* lib_set_h */