[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] | 35 | typedef 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] | 44 | typedef 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 |
|
---|
| 54 | typedef struct {
|
---|
| 55 | zAVLNode *top;
|
---|
| 56 | long count;
|
---|
| 57 | zAVLKey (*getkey)(const void *item);
|
---|
[363] | 58 | int keytype;
|
---|
[1] | 59 | } zAVLTree;
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | typedef struct {
|
---|
| 63 | const zAVLTree *avltree;
|
---|
| 64 | const zAVLNode *curnode;
|
---|
| 65 | } zAVLCursor;
|
---|
| 66 |
|
---|
| 67 |
|
---|
[363] | 68 | extern zAVLTree *zAVLAllocTree (zAVLKey (*getkey)(void const *item), int keytype);
|
---|
[1] | 69 | extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item));
|
---|
| 70 | extern int zAVLInsert (zAVLTree *avltree, void *item);
|
---|
| 71 | extern void *zAVLSearch (zAVLTree const *avltree, zAVLKey key);
|
---|
| 72 | extern int zAVLDelete (zAVLTree *avltree, zAVLKey key);
|
---|
| 73 | extern void *zAVLFirst (zAVLCursor *avlcursor, zAVLTree const *avltree);
|
---|
| 74 | extern void *zAVLNext (zAVLCursor *avlcursor);
|
---|
| 75 |
|
---|
[452] | 76 | extern char * zAVL_string_get (zAVLTree * tree, char * key);
|
---|
| 77 | /* uses strdup to insert a copy */
|
---|
| 78 | extern int zAVL_string_set (zAVLTree ** tree, const char * key);
|
---|
| 79 | extern void zAVL_string_reset (zAVLTree * tree);
|
---|
| 80 |
|
---|
[1] | 81 | #endif
|
---|