Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* |
2 | * zAVLTree.h: Header file for AVLTrees with string keys. |
||
3 | * Copyright (C) 1998 Michael H. Buselli |
||
4 | * |
||
5 | * This library is free software; you can redistribute it and/or |
||
6 | * modify it under the terms of the GNU Library General Public |
||
7 | * License as published by the Free Software Foundation; either |
||
8 | * version 2 of the License, or (at your option) any later version. |
||
9 | * |
||
10 | * This library 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 GNU |
||
13 | * Library General Public License for more details. |
||
14 | * |
||
15 | * You should have received a copy of the GNU Library General Public |
||
16 | * License along with this library; if not, write to the Free |
||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | * |
||
19 | * The author of this library can be reached at the following address: |
||
20 | * Michael H. Buselli |
||
21 | * 4334 N. Hazel St. #515 |
||
22 | * Chicago, IL 60613-1456 |
||
23 | * |
||
24 | * Or you can send email to |
||
25 | * The official web page for this product is: |
||
26 | * http://www.tezcat.com/~cosine/pub/AVLTree/ |
||
27 | * |
||
28 | * This is version 0.1.0 (alpha). |
||
29 | */ |
||
30 | |||
31 | #ifndef _ZAVLTREE_H_ |
||
32 | #define _ZAVLTREE_H_ |
||
33 | |||
34 | |||
35 | typedef struct _zAVLNode { |
||
36 | const char *key; |
||
37 | long depth; |
||
38 | void *item; |
||
39 | struct _zAVLNode *parent; |
||
40 | struct _zAVLNode *left; |
||
41 | struct _zAVLNode *right; |
||
42 | } zAVLNode; |
||
43 | |||
44 | |||
45 | typedef struct { |
||
46 | zAVLNode *top; |
||
47 | long count; |
||
48 | const char *(*getkey)(const void *item); |
||
49 | } zAVLTree; |
||
50 | |||
51 | |||
52 | typedef struct { |
||
53 | const zAVLTree *avltree; |
||
54 | const zAVLNode *curnode; |
||
55 | } zAVLCursor; |
||
56 | |||
57 | |||
58 | extern zAVLTree *zAVLAllocTree (const char *(*getkey)(void const *item)); |
||
59 | extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item)); |
||
60 | extern int zAVLInsert (zAVLTree *avltree, void *item); |
||
61 | extern void *zAVLSearch (zAVLTree const *avltree, const char *key); |
||
62 | extern int zAVLDelete (zAVLTree *avltree, const char *key); |
||
63 | extern void *zAVLFirst (zAVLCursor *avlcursor, zAVLTree const *avltree); |
||
64 | extern void *zAVLNext (zAVLCursor *avlcursor); |
||
65 | |||
66 | |||
67 | #endif |