VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/table/avl_Get.cpp.h@ 18188

Last change on this file since 18188 was 8155, checked in by vboxsync, 17 years ago

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1/* $Id: avl_Get.cpp.h 8155 2008-04-18 15:16:47Z vboxsync $ */
2/** @file
3 * kAVLGet - get routine for AVL trees.
4 */
5
6/*
7 * Copyright (C) 1999-2002 knut st. osmundsen ([email protected])
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef _kAVLGet_h_
32#define _kAVLGet_h_
33
34
35/**
36 * Gets a node from the tree (does not remove it!)
37 * @returns Pointer to the node holding the given key.
38 * @param ppTree Pointer to the AVL-tree root node pointer.
39 * @param Key Key value of the node which is to be found.
40 * @author knut st. osmundsen
41 */
42RTDECL(PKAVLNODECORE) KAVL_FN(Get)(PPKAVLNODECORE ppTree, KAVLKEY Key)
43{
44 register PKAVLNODECORE pNode = KAVL_GET_POINTER_NULL(ppTree);
45
46 if (pNode)
47 {
48 while (KAVL_NE(pNode->Key, Key))
49 {
50 if (KAVL_G(pNode->Key, Key))
51 {
52 if (pNode->pLeft != KAVL_NULL)
53 pNode = KAVL_GET_POINTER(&pNode->pLeft);
54 else
55 return NULL;
56 }
57 else
58 {
59 if (pNode->pRight != KAVL_NULL)
60 pNode = KAVL_GET_POINTER(&pNode->pRight);
61 else
62 return NULL;
63 }
64 }
65 }
66
67 return pNode;
68}
69
70
71#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette