From 58bcdbb875354d39246370b0be71d637ecf5f5de Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Fri, 4 Aug 2006 11:57:52 +0000 Subject: use the tree for the tagTracker. git-svn-id: https://svn.musicpd.org/mpd/branches/mpd-tree@4545 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/tree.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/tree.h') 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 -- cgit v1.2.3