summaryrefslogtreecommitdiff
path: root/cesar/lib/aatree.h
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/lib/aatree.h
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/lib/aatree.h')
-rw-r--r--cesar/lib/aatree.h117
1 files changed, 117 insertions, 0 deletions
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
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \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 */