aboutsummaryrefslogtreecommitdiffstats
path: root/src/tree.h
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2006-07-30 18:43:13 +0000
committerWarren Dukes <warren.dukes@gmail.com>2006-07-30 18:43:13 +0000
commit71fe871908db4317e5afd4308a044909a1799c9e (patch)
treeb6605a973562be001afa7b22372c7f5c9eefbded /src/tree.h
parent263a9d583a74a94fef652bb40f4035b9c0c1612e (diff)
downloadmpd-71fe871908db4317e5afd4308a044909a1799c9e.tar.gz
mpd-71fe871908db4317e5afd4308a044909a1799c9e.tar.xz
mpd-71fe871908db4317e5afd4308a044909a1799c9e.zip
tree updates:
*) when CHILDREN_PER_NODE is large, use binary search *) add a iterator implementation *) some code cleanup git-svn-id: https://svn.musicpd.org/mpd/trunk@4492 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/tree.h41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/tree.h b/src/tree.h
index 737f914d2..c47b15144 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -1,36 +1,31 @@
-#define CHILDREN_PER_NODE 3
-#define DATA_PER_NODE 2
+#ifndef TREE_H
+#define TREE_H
-typedef struct _TreeNode
-{
- void * data[DATA_PER_NODE];
- struct _TreeNode * parent;
- struct _TreeNode * children[CHILDREN_PER_NODE];
- unsigned dataCount;
-} TreeNode;
-
-typedef int (*TreeCompareDataFunction)(void * data1, void * data2);
-typedef void (*TreeFreeDataFunction)(void * data);
-
-typedef struct _Tree
-{
- TreeCompareDataFunction compareData;
- TreeFreeDataFunction freeData;
- TreeNode * rootNode;
-} Tree;
+typedef struct _Tree Tree;
+typedef struct _TreeNode TreeNode;
+typedef struct _TreeIterator TreeIterator;
-typedef struct _TreeIterator
+struct _TreeIterator
{
Tree * tree;
TreeNode * node;
- unsigned which;
-} TreeIterator;
+ int which;
+};
+
+typedef int (*TreeCompareDataFunction)(const void * data1, const void * data2);
+typedef void (*TreeFreeDataFunction)(void * data);
Tree * MakeTree(TreeCompareDataFunction compareFunc,
TreeFreeDataFunction freeData);
-void SetIteratorToBegin(TreeIterator * iter, Tree * tree);
+void SetTreeIteratorToBegin(TreeIterator * iter, Tree * tree);
+int IsTreeIteratorAtEnd(const TreeIterator * iter);
+void IncrementTreeIterator(TreeIterator * iter);
+
+void * GetDataFromTreeIterator(TreeIterator * iter);
int InsertIntoTree(Tree * tree, void * data);
void DeleteFromTree(Tree * tree, void * data);
+
+#endif