VirtualBox

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

Last change on this file since 65817 was 65208, checked in by vboxsync, 8 years ago

Runtime/AVL: fixed headers

  • 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 65208 2017-01-09 14:39:54Z vboxsync $ */
2/** @file
3 * kAVLGet - get routine for AVL trees.
4 */
5
6/*
7 * Copyright (C) 1999-2012 knut st. osmundsen ([email protected])
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
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 */
42KAVL_DECL(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