VirtualBox

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

Last change on this file since 5422 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/* $Id: avl_Get.cpp.h 4071 2007-08-07 17:07:59Z 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
18#ifndef _kAVLGet_h_
19#define _kAVLGet_h_
20
21
22/**
23 * Gets a node from the tree (does not remove it!)
24 * @returns Pointer to the node holding the given key.
25 * @param ppTree Pointer to the AVL-tree root node pointer.
26 * @param Key Key value of the node which is to be found.
27 * @author knut st. osmundsen
28 */
29RTDECL(PKAVLNODECORE) KAVL_FN(Get)(PPKAVLNODECORE ppTree, KAVLKEY Key)
30{
31 register PKAVLNODECORE pNode = KAVL_GET_POINTER_NULL(ppTree);
32
33 if (pNode)
34 {
35 while (KAVL_NE(pNode->Key, Key))
36 {
37 if (KAVL_G(pNode->Key, Key))
38 {
39 if (pNode->pLeft != KAVL_NULL)
40 pNode = KAVL_GET_POINTER(&pNode->pLeft);
41 else
42 return NULL;
43 }
44 else
45 {
46 if (pNode->pRight != KAVL_NULL)
47 pNode = KAVL_GET_POINTER(&pNode->pRight);
48 else
49 return NULL;
50 }
51 }
52 }
53
54 return pNode;
55}
56
57
58#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