source: trunk/src/win32k/include/avl.h@ 5087

Last change on this file since 5087 was 3168, checked in by bird, 25 years ago

Synced with \tools\fastdep\avl.*

File size: 2.7 KB
Line 
1/* $Id: avl.h,v 1.3 2000-03-19 16:00:10 bird Exp $
2 *
3 * AVL-Tree (lookalike) declaration.
4 *
5 * This AVL implementation is configurable from this headerfile. By
6 * for example alterning the AVLKEY typedefinition an the AVL_<L|G|E|N>[E]
7 * macros you are able to create different trees. Currently you may only have
8 * one type of trees within one program (module).
9 *
10 * TREETYPE: unsigned long key.
11 *
12 *
13 * Copyright (c) 1999-2000 knut st. osmundsen
14 *
15 * Project Odin Software License can be found in LICENSE.TXT
16 *
17 */
18#ifndef _AVL_H_
19#define _AVL_H_
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*
26 * AVL configuration. PRIVATE!
27 */
28#define AVL_MAX_HEIGHT 19 /* Up to 2^16 nodes. */
29#undef AVL_MAY_TRY_INSERT_EQUAL /* No duplicate key! */
30
31
32/*
33 * AVL Compare macros
34 */
35#define AVL_L(key1, key2) ((key1) < (key2))
36#define AVL_LE(key1, key2) ((key1) <= (key2))
37#define AVL_G(key1, key2) ((key1) > (key2))
38#define AVL_GE(key1, key2) ((key1) >= (key2))
39#define AVL_E(key1, key2) ((key1) == (key2))
40#define AVL_NE(key1, key2) ((key1) != (key2))
41
42
43/**
44 * AVL key type
45 */
46typedef unsigned long AVLKEY;
47
48
49/**
50 * AVL Core node.
51 */
52typedef struct _AVLNodeCore
53{
54 AVLKEY Key; /* Key value. */
55 struct _AVLNodeCore * pLeft; /* Pointer to left leaf node. */
56 struct _AVLNodeCore * pRight; /* Pointer to right leaf node. */
57 unsigned char uchHeight; /* Height of this tree: max(heigth(left), heigth(right)) + 1 */
58} AVLNODECORE, *PAVLNODECORE, **PPAVLNODECORE;
59
60
61/**
62 * AVL Enum data - All members are PRIVATE! Don't touch!
63 */
64typedef struct _AVLEnumData
65{
66 char fFromLeft;
67 char cEntries;
68 char achFlags[AVL_MAX_HEIGHT];
69 PAVLNODECORE aEntries[AVL_MAX_HEIGHT];
70} AVLENUMDATA, *PAVLENUMDATA;
71
72
73/*
74 * callback type
75 */
76typedef unsigned ( _PAVLCALLBACK)(PAVLNODECORE, void*);
77typedef _PAVLCALLBACK *PAVLCALLBACK;
78
79
80BOOL AVLInsert(PPAVLNODECORE ppTree, PAVLNODECORE pNode);
81PAVLNODECORE AVLRemove(PPAVLNODECORE ppTree, AVLKEY Key);
82PAVLNODECORE AVLGet(PPAVLNODECORE ppTree, AVLKEY Key);
83PAVLNODECORE AVLGetWithParent(PPAVLNODECORE ppTree, PPAVLNODECORE ppParent, AVLKEY Key);
84PAVLNODECORE AVLGetWithAdjecentNodes(PPAVLNODECORE ppTree, AVLKEY Key, PPAVLNODECORE ppLeft, PPAVLNODECORE ppRight);
85unsigned AVLDoWithAll(PPAVLNODECORE ppTree, int fFromLeft, PAVLCALLBACK pfnCallBack, void *pvParam);
86PAVLNODECORE AVLBeginEnumTree(PPAVLNODECORE ppTree, PAVLENUMDATA pEnumData, int fFromLeft);
87PAVLNODECORE AVLGetNextNode(PAVLENUMDATA pEnumData);
88PAVLNODECORE AVLGetBestFit(PPAVLNODECORE ppTree, AVLKEY Key, int fAbove);
89
90
91
92/*
93 * Just in case NULL is undefined.
94 */
95#ifndef NULL
96 #define NULL ((void*)0)
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
Note: See TracBrowser for help on using the repository browser.