From 3d58a62727346b7ac1a6cb36fed1a06ed72228dd Mon Sep 17 00:00:00 2001 From: save Date: Mon, 7 Apr 2008 14:17:42 +0000 Subject: Moved the complete svn base into the cesar directory. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/lib/aatree.h | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 cesar/lib/aatree.h (limited to 'cesar/lib/aatree.h') diff --git a/cesar/lib/aatree.h b/cesar/lib/aatree.h new file mode 100644 index 0000000000..0acab1d155 --- /dev/null +++ b/cesar/lib/aatree.h @@ -0,0 +1,117 @@ +#ifndef lib_aatree_h +#define lib_aatree_h +/* Cesar project {{{ + * + * Copyright (C) 2007 Spidcom + * + * <<>> + * + * }}} */ +/** + * \file lib/aatree.h + * \brief Arne Andersson Trees. + * \ingroup lib + */ + +/* Set node. */ +struct set_node_t +{ + /** Pointer to parent node. */ + set_node_t *father; + /** Pointer to left and right children. */ + set_node_t *left, *right; + /** Node level. */ + uint level; +}; +/* Forward declaration in lib/set.h. */ + +BEGIN_DECLS + +/** + * Initialise a set. + * \param set the set + * \param less the "is lesser than" comparison function + */ +void +set_init (set_t *set, set_node_less_t less); + +/** + * Initialise a set node. + * \param node the node to initialise + */ +void +set_node_init (set_node_t *node); + +/** + * Find a node inside a set. + * \param set the set to look into + * \param node node to compare with nodes inside the set + * \return the found node or NULL if none found + * + * The \a node parameter just have to contains enough data to be used with the + * comparison function. + */ +set_node_t * +set_find (set_t *set, set_node_t *node); + +/** + * Insert a node. + * \param set the set + * \param node node to insert + * \return true if successful (not in the set yet) + */ +bool +set_insert (set_t *set, set_node_t *node); + +/** + * Remove a node from the set. + * \param set the set + * \param node the node to remove + * + * The node must be inside the set. + */ +void +set_remove (set_t *set, set_node_t *node); + +/** + * Return the first node. + * \param set the set + * \return the minimum node + */ +set_node_t * +set_begin (set_t *set); + +/** + * Return the node after the last one. + * \param set the set + * \return past the last node + */ +extern inline set_node_t * +set_end (set_t *set) +{ + return NULL; +} + +/** + * Return the next node. + * \param set the set + * \param node current node + * \return the following node + */ +set_node_t * +set_next (set_t *set, set_node_t *node); + +/** + * Return whether the set is empty. + * \param set the set + * \return true if empty + */ +extern inline bool +set_empty (set_t *set) +{ + return set->root->level == 0; +} + +END_DECLS + +#endif /* lib_aatree_h */ -- cgit v1.2.3 19b19eb4301af2016875b9f4f6e82'>clueboard
diff options
context: