source: trunk/include/zAVLTree.h@ 353

Last change on this file since 353 was 1, checked in by katerina, 19 years ago

Initial import

File size: 2.2 KB
RevLine 
[1]1/*
2 * zAVLTree.h: Header file for zAVLTrees.
3 * Copyright (C) 1998,2001 Michael H. Buselli
4 * This is version 0.1.3 (alpha).
5 * Generated from $Id: xAVLTree.h.sh,v 1.5 2001/06/07 06:58:28 cosine Exp $
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * The author of this library can be reached at the following address:
22 * Michael H. Buselli
23 * 30051 N. Waukegan Rd. Apt. 103
24 * Lake Bluff, IL 60044-5412
25 *
26 * Or you can send email to <cosine@cosine.org>.
27 * The official web page for this product is:
28 * http://www.cosine.org/project/AVLTree/
29 */
30
31#ifndef _ZAVLTREE_H_
32#define _ZAVLTREE_H_
33
34/* typedef the keytype */
35typedef const char * zAVLKey;
36
37/* Comparison function for strings is strcmp(). */
38#define zAVLKey_cmp(tree, a, b) (strcmp((a), (b)))
39
40
41typedef struct _zAVLNode {
42 zAVLKey key;
43 long depth;
44 void *item;
45 struct _zAVLNode *parent;
46 struct _zAVLNode *left;
47 struct _zAVLNode *right;
48} zAVLNode;
49
50
51typedef struct {
52 zAVLNode *top;
53 long count;
54 zAVLKey (*getkey)(const void *item);
55} zAVLTree;
56
57
58typedef struct {
59 const zAVLTree *avltree;
60 const zAVLNode *curnode;
61} zAVLCursor;
62
63
64extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item));
65extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item));
66extern int zAVLInsert (zAVLTree *avltree, void *item);
67extern void *zAVLSearch (zAVLTree const *avltree, zAVLKey key);
68extern int zAVLDelete (zAVLTree *avltree, zAVLKey key);
69extern void *zAVLFirst (zAVLCursor *avlcursor, zAVLTree const *avltree);
70extern void *zAVLNext (zAVLCursor *avlcursor);
71
72#endif
Note: See TracBrowser for help on using the repository browser.