Update to 6762
[qball-mpd.git] / src / tree.h
blob76a980cd2df19c68ffc067e6cce4eb78488db432
1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2006-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * This project's homepage is: http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef TREE_H
20 #define TREE_H
22 typedef struct _Tree Tree;
23 typedef struct _TreeNode TreeNode;
24 typedef struct _TreeIterator TreeIterator;
25 typedef struct _TreeKeyData TreeKeyData;
27 struct _TreeIterator
29 Tree * tree;
30 TreeNode * node;
31 int which;
34 struct _TreeKeyData
36 void * key;
37 void * data;
40 typedef int (*TreeCompareKeyFunction)(const void * key1, const void * key2);
41 typedef void (*TreeFreeFunction)(void * data);
43 Tree * MakeTree(TreeCompareKeyFunction compareFunc,
44 TreeFreeFunction freeKey,
45 TreeFreeFunction freeData);
46 void FreeTree(Tree * tree);
48 int GetTreeSize(Tree * tree);
50 void SetTreeIteratorToBegin(Tree * tree, TreeIterator * iter);
51 int IsTreeIteratorAtEnd(const TreeIterator * iter);
52 void IncrementTreeIterator(TreeIterator * iter);
54 TreeKeyData GetTreeKeyData(TreeIterator * iter);
56 int InsertInTree(Tree * tree, void * key, void * data);
57 int RemoveFromTreeByKey(Tree * tree, void * key);
58 void RemoveFromTreeByIterator(Tree * tree, TreeIterator * iter);
60 int FindInTree(Tree * tree, void * key, TreeIterator * iter /* can be NULL */);
62 #endif