aboutsummaryrefslogtreecommitdiffstats
path: root/src/tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tree.h')
-rw-r--r--src/tree.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/tree.h b/src/tree.h
index 6f53a9145..54416a065 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -22,6 +22,7 @@
typedef struct _Tree Tree;
typedef struct _TreeNode TreeNode;
typedef struct _TreeIterator TreeIterator;
+typedef struct _TreeKeyData TreeKeyData;
struct _TreeIterator
{
@@ -30,20 +31,32 @@ struct _TreeIterator
int which;
};
-typedef int (*TreeCompareDataFunction)(const void * data1, const void * data2);
-typedef void (*TreeFreeDataFunction)(void * data);
+struct _TreeKeyData
+{
+ void * key;
+ void * data;
+};
+
+typedef int (*TreeCompareKeyFunction)(const void * key1, const void * key2);
+typedef void (*TreeFreeFunction)(void * data);
+
+Tree * MakeTree(TreeCompareKeyFunction compareFunc,
+ TreeFreeFunction freeKey,
+ TreeFreeFunction freeData);
+void FreeTree(Tree * tree);
-Tree * MakeTree(TreeCompareDataFunction compareFunc,
- TreeFreeDataFunction freeData);
+int GetTreeSize(Tree * tree);
-void SetTreeIteratorToBegin(TreeIterator * iter, Tree * tree);
+void SetTreeIteratorToBegin(Tree * tree, TreeIterator * iter);
int IsTreeIteratorAtEnd(const TreeIterator * iter);
void IncrementTreeIterator(TreeIterator * iter);
-void * GetDataFromTreeIterator(TreeIterator * iter);
+TreeKeyData GetTreeKeyData(TreeIterator * iter);
-int InsertIntoTree(Tree * tree, void * data);
+int InsertInTree(Tree * tree, void * key, void * data);
+int RemoveFromTreeByKey(Tree * tree, void * key);
+void RemoveFromTreeByIterator(Tree * tree, TreeIterator * iter);
-int DeleteFromTree(Tree * tree, void * data);
+int FindInTree(Tree * tree, void * key, TreeIterator * iter /* can be NULL */);
#endif