VirtualBox

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

Last change on this file since 980 was 402, checked in by vboxsync, 18 years ago

Added missing RTDECL so it'll compile cleanly in Ring-0 on NT where default calling convention is stdcall and not cdecl like RTCALL.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/* $Id: avl_Get.cpp.h 402 2007-01-28 08:44:20Z vboxsync $ */
2/** @file
3 * kAVLGet - get routine for AVL trees.
4 */
5
6/*
7 * Copyright (C) 1999-2002 knut st. osmundsen (bird-src-spam@anduin.net)
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef _kAVLGet_h_
23#define _kAVLGet_h_
24
25
26/**
27 * Gets a node from the tree (does not remove it!)
28 * @returns Pointer to the node holding the given key.
29 * @param ppTree Pointer to the AVL-tree root node pointer.
30 * @param Key Key value of the node which is to be found.
31 * @author knut st. osmundsen
32 */
33RTDECL(PKAVLNODECORE) KAVL_FN(Get)(PPKAVLNODECORE ppTree, KAVLKEY Key)
34{
35 register PKAVLNODECORE pNode = KAVL_GET_POINTER_NULL(ppTree);
36
37 if (pNode)
38 {
39 while (KAVL_NE(pNode->Key, Key))
40 {
41 if (KAVL_G(pNode->Key, Key))
42 {
43 if (pNode->pLeft != KAVL_NULL)
44 pNode = KAVL_GET_POINTER(&pNode->pLeft);
45 else
46 return NULL;
47 }
48 else
49 {
50 if (pNode->pRight != KAVL_NULL)
51 pNode = KAVL_GET_POINTER(&pNode->pRight);
52 else
53 return NULL;
54 }
55 }
56 }
57
58 return pNode;
59}
60
61
62#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