1 | /* $Id: avl_Enum.cpp.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Enumeration routines for AVL trees.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef _kAVLEnum_h_
|
---|
38 | #define _kAVLEnum_h_
|
---|
39 |
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Gets the root node.
|
---|
43 | *
|
---|
44 | * @returns Pointer to the root node.
|
---|
45 | * @returns NULL if the tree is empty.
|
---|
46 | *
|
---|
47 | * @param ppTree Pointer to pointer to the tree root node.
|
---|
48 | */
|
---|
49 | KAVL_DECL(PKAVLNODECORE) KAVL_FN(GetRoot)(PPKAVLNODECORE ppTree)
|
---|
50 | {
|
---|
51 | return KAVL_GET_POINTER_NULL(ppTree);
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Gets the right node.
|
---|
57 | *
|
---|
58 | * @returns Pointer to the right node.
|
---|
59 | * @returns NULL if no right node.
|
---|
60 | *
|
---|
61 | * @param pNode The current node.
|
---|
62 | */
|
---|
63 | KAVL_DECL(PKAVLNODECORE) KAVL_FN(GetRight)(PKAVLNODECORE pNode)
|
---|
64 | {
|
---|
65 | if (pNode)
|
---|
66 | return KAVL_GET_POINTER_NULL(&pNode->pRight);
|
---|
67 | return NULL;
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Gets the left node.
|
---|
73 | *
|
---|
74 | * @returns Pointer to the left node.
|
---|
75 | * @returns NULL if no left node.
|
---|
76 | *
|
---|
77 | * @param pNode The current node.
|
---|
78 | */
|
---|
79 | KAVL_DECL(PKAVLNODECORE) KAVL_FN(GetLeft)(PKAVLNODECORE pNode)
|
---|
80 | {
|
---|
81 | if (pNode)
|
---|
82 | return KAVL_GET_POINTER_NULL(&pNode->pLeft);
|
---|
83 | return NULL;
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | # ifdef KAVL_EQUAL_ALLOWED
|
---|
88 | /**
|
---|
89 | * Gets the next node with an equal (start) key.
|
---|
90 | *
|
---|
91 | * @returns Pointer to the next equal node.
|
---|
92 | * @returns NULL if the current node was the last one with this key.
|
---|
93 | *
|
---|
94 | * @param pNode The current node.
|
---|
95 | */
|
---|
96 | KAVL_DECL(PKAVLNODECORE) KAVL_FN(GetNextEqual)(PKAVLNODECORE pNode)
|
---|
97 | {
|
---|
98 | if (pNode)
|
---|
99 | return KAVL_GET_POINTER_NULL(&pNode->pList);
|
---|
100 | return NULL;
|
---|
101 | }
|
---|
102 | # endif /* KAVL_EQUAL_ALLOWED */
|
---|
103 |
|
---|
104 | #endif
|
---|
105 |
|
---|