aboutsummaryrefslogtreecommitdiffstats
path: root/src/tree.h
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2006-07-30 07:58:56 +0000
committerWarren Dukes <warren.dukes@gmail.com>2006-07-30 07:58:56 +0000
commita0c8e3656ba1c7c796f47f7d020f448961b1b3c5 (patch)
treed113b71ab4c5a5db448cb4e0bdbcf4b2f38f60e7 /src/tree.h
parentb38c3fa1bbd67bcae1718fc9fe0cb42a9a5d1f6c (diff)
downloadmpd-a0c8e3656ba1c7c796f47f7d020f448961b1b3c5.tar.gz
mpd-a0c8e3656ba1c7c796f47f7d020f448961b1b3c5.tar.xz
mpd-a0c8e3656ba1c7c796f47f7d020f448961b1b3c5.zip
beginnings of a B-tree, currently insertion has been implemented and test
git-svn-id: https://svn.musicpd.org/mpd/trunk@4487 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/tree.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tree.h b/src/tree.h
new file mode 100644
index 000000000..737f914d2
--- /dev/null
+++ b/src/tree.h
@@ -0,0 +1,36 @@
+#define CHILDREN_PER_NODE 3
+#define DATA_PER_NODE 2
+
+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 _TreeIterator
+{
+ Tree * tree;
+ TreeNode * node;
+ unsigned which;
+} TreeIterator;
+
+Tree * MakeTree(TreeCompareDataFunction compareFunc,
+ TreeFreeDataFunction freeData);
+
+void SetIteratorToBegin(TreeIterator * iter, Tree * tree);
+
+int InsertIntoTree(Tree * tree, void * data);
+
+void DeleteFromTree(Tree * tree, void * data);