VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/table/avl_Range.cpp.h@ 32599

Last change on this file since 32599 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* $Id: avl_Range.cpp.h 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * kAVLRange - Range routines for AVL trees.
4 */
5
6/*
7 * Copyright (C) 1999-2006 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
27#ifndef _kAVLRange_h_
28#define _kAVLRange_h_
29
30/**
31 * Finds the range containing the specified key.
32 *
33 * @returns Pointer to the matching range.
34 *
35 * @param ppTree Pointer to Pointer to the tree root node.
36 * @param Key The Key to find matching range for.
37 */
38RTDECL(PKAVLNODECORE) KAVL_FN(RangeGet)(PPKAVLNODECORE ppTree, register KAVLKEY Key)
39{
40 register PKAVLNODECORE pNode = KAVL_GET_POINTER_NULL(ppTree);
41 if (pNode)
42 {
43 for (;;)
44 {
45 if (KAVL_R_IS_IN_RANGE(pNode->Key, pNode->KeyLast, Key))
46 return pNode;
47 if (KAVL_G(pNode->Key, Key))
48 {
49 if (pNode->pLeft != KAVL_NULL)
50 pNode = KAVL_GET_POINTER(&pNode->pLeft);
51 else
52 return NULL;
53 }
54 else
55 {
56 if (pNode->pRight != KAVL_NULL)
57 pNode = KAVL_GET_POINTER(&pNode->pRight);
58 else
59 return NULL;
60 }
61 }
62 }
63
64 return NULL;
65}
66
67
68/**
69 * Removes the range containing the specified key.
70 *
71 * @returns Pointer to the matching range.
72 *
73 * @param ppTree Pointer to Pointer to the tree root node.
74 * @param Key The Key to remove matching range for.
75 */
76RTDECL(PKAVLNODECORE) KAVL_FN(RangeRemove)(PPKAVLNODECORE ppTree, KAVLKEY Key)
77{
78 PKAVLNODECORE pNode = KAVL_FN(RangeGet)(ppTree, Key);
79 if (pNode)
80 return KAVL_FN(Remove)(ppTree, pNode->Key);
81 return NULL;
82}
83
84#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