source: trunk/include/zAVLTree.h@ 367

Last change on this file since 367 was 363, checked in by katerina, 13 years ago

Change zAVL implementation to allow integer keys.

File size: 2.3 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 */
[363]35typedef const void * zAVLKey;
[1]36
37/* Comparison function for strings is strcmp(). */
[363]38/* #define zAVLKey_cmp(tree, a, b) (strcmp((a), (b))) */
[1]39
[363]40#define zAVL_KEY_STRING 0
41#define zAVL_KEY_INT 1
[1]42
[363]43
[1]44typedef struct _zAVLNode {
45 zAVLKey key;
46 long depth;
47 void *item;
48 struct _zAVLNode *parent;
49 struct _zAVLNode *left;
50 struct _zAVLNode *right;
51} zAVLNode;
52
53
54typedef struct {
55 zAVLNode *top;
56 long count;
57 zAVLKey (*getkey)(const void *item);
[363]58 int keytype;
[1]59} zAVLTree;
60
61
62typedef struct {
63 const zAVLTree *avltree;
64 const zAVLNode *curnode;
65} zAVLCursor;
66
67
[363]68extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype);
[1]69extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item));
70extern int zAVLInsert (zAVLTree *avltree, void *item);
71extern void *zAVLSearch (zAVLTree const *avltree, zAVLKey key);
72extern int zAVLDelete (zAVLTree *avltree, zAVLKey key);
73extern void *zAVLFirst (zAVLCursor *avlcursor, zAVLTree const *avltree);
74extern void *zAVLNext (zAVLCursor *avlcursor);
75
76#endif
Note: See TracBrowser for help on using the repository browser.