avl.h revision 56d1bed39a250f8a316da18cd3e4f6aa3d3c02e4
16416N/A/** @file
16416N/A * InnoTek Portable Runtime - AVL Trees.
16416N/A */
16416N/A
16416N/A/*
16416N/A * Copyright (C) 2006 InnoTek Systemberatung GmbH
16416N/A * Copyright (C) 1999-2003 knut st. osmundsen <bird-src-spam@anduin.net>
16416N/A *
16416N/A * This file is part of VirtualBox Open Source Edition (OSE), as
16416N/A * available from http://www.virtualbox.org. This file is free software;
16416N/A * you can redistribute it and/or modify it under the terms of the GNU
16416N/A * General Public License as published by the Free Software Foundation,
16416N/A * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
16416N/A * distribution. VirtualBox OSE is distributed in the hope that it will
16416N/A * be useful, but WITHOUT ANY WARRANTY of any kind.
16416N/A *
16416N/A * If you received this file as part of a commercial VirtualBox
16416N/A * distribution, then only the terms of your commercial VirtualBox
16416N/A * license agreement apply instead of the previous paragraph.
16416N/A */
16416N/A
16416N/A#ifndef __iprt_avl_h__
16416N/A#define __iprt_avl_h__
16416N/A
16416N/A#include <iprt/cdefs.h>
16416N/A#include <iprt/types.h>
16416N/A
16416N/A__BEGIN_DECLS
16416N/A
16416N/A/** @defgroup grp_rt_avl RTAvl - AVL Trees
16416N/A * @ingroup grp_rt
16416N/A * @{
16416N/A */
16416N/A
16416N/A
16416N/A/** AVL tree of void pointers.
16416N/A * @{
16416N/A */
16416N/A
16416N/A/**
16416N/A * AVL key type
16416N/A */
16416N/Atypedef void * AVLPVKEY;
16416N/A
16416N/A/**
16416N/A * AVL Core node.
16416N/A */
16416N/Atypedef struct _AVLPVNodeCore
16416N/A{
16416N/A AVLPVKEY Key; /** Key value. */
16416N/A struct _AVLPVNodeCore *pLeft; /** Pointer to left leaf node. */
16416N/A struct _AVLPVNodeCore *pRight; /** Pointer to right leaf node. */
16416N/A unsigned char uchHeight; /** Height of this tree: max(height(left), height(right)) + 1 */
16416N/A} AVLPVNODECORE, *PAVLPVNODECORE, **PPAVLPVNODECORE;
16416N/A
16416N/A/** A tree with void pointer keys. */
16416N/Atypedef PAVLPVNODECORE AVLPVTREE;
16416N/A/** Pointer to a tree with void pointer keys. */
16416N/Atypedef PPAVLPVNODECORE PAVLPVTREE;
16416N/A
16416N/A/** Callback function for AVLPVDoWithAll(). */
16416N/Atypedef DECLCALLBACK(int) AVLPVCALLBACK(PAVLPVNODECORE, void *);
16416N/A/** Pointer to callback function for AVLPVDoWithAll(). */
16416N/Atypedef AVLPVCALLBACK *PAVLPVCALLBACK;
16416N/A
16416N/A/*
16416N/A * Functions.
16416N/A */
16416N/ARTDECL(bool) RTAvlPVInsert(PAVLPVTREE ppTree, PAVLPVNODECORE pNode);
16416N/ARTDECL(PAVLPVNODECORE) RTAvlPVRemove(PAVLPVTREE ppTree, AVLPVKEY Key);
16416N/ARTDECL(PAVLPVNODECORE) RTAvlPVGet(PAVLPVTREE ppTree, AVLPVKEY Key);
16416N/ARTDECL(PAVLPVNODECORE) RTAvlPVGetBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
16416N/ARTDECL(PAVLPVNODECORE) RTAvlPVRemoveBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
16416N/ARTDECL(int) RTAvlPVDoWithAll(PAVLPVTREE ppTree, int fFromLeft, PAVLPVCALLBACK pfnCallBack, void *pvParam);
16416N/ARTDECL(int) RTAvlPVDestroy(PAVLPVTREE ppTree, PAVLPVCALLBACK pfnCallBack, void *pvParam);
16416N/A
16416N/A/** @} */
16416N/A
16416N/A
16416N/A/** AVL tree of unsigned long.
16416N/A * @{
16416N/A */
16416N/A
16416N/A/**
16416N/A * AVL key type
16416N/A */
16416N/Atypedef unsigned long AVLULKEY;
16416N/A
16416N/A/**
16416N/A * AVL Core node.
16416N/A */
16416N/Atypedef struct _AVLULNodeCore
16416N/A{
16416N/A AVLULKEY Key; /** Key value. */
16416N/A struct _AVLULNodeCore *pLeft; /** Pointer to left leaf node. */
16416N/A struct _AVLULNodeCore *pRight; /** Pointer to right leaf node. */
16416N/A unsigned char uchHeight; /** Height of this tree: max(height(left), height(right)) + 1 */
16416N/A} AVLULNODECORE, *PAVLULNODECORE, **PPAVLULNODECORE;
16416N/A
16416N/A
16416N/A/** Callback function for AVLULDoWithAll(). */
16416N/Atypedef DECLCALLBACK(int) AVLULCALLBACK(PAVLULNODECORE, void*);
16416N/A/** Pointer to callback function for AVLULDoWithAll(). */
16416N/Atypedef AVLULCALLBACK *PAVLULCALLBACK;
16416N/A
16416N/A
16416N/A/*
16416N/A * Functions.
16416N/A */
16416N/ARTDECL(bool) RTAvlULInsert(PPAVLULNODECORE ppTree, PAVLULNODECORE pNode);
16416N/ARTDECL(PAVLULNODECORE) RTAvlULRemove(PPAVLULNODECORE ppTree, AVLULKEY Key);
16416N/ARTDECL(PAVLULNODECORE) RTAvlULGet(PPAVLULNODECORE ppTree, AVLULKEY Key);
16416N/ARTDECL(PAVLULNODECORE) RTAvlULGetBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
16416N/ARTDECL(PAVLULNODECORE) RTAvlULRemoveBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
16416N/ARTDECL(int) RTAvlULDoWithAll(PPAVLULNODECORE ppTree, int fFromLeft, PAVLULCALLBACK pfnCallBack, void *pvParam);
16416N/A
16416N/A/** @} */
16416N/A
16416N/A
16416N/A
16416N/A/** AVL tree of uint32_t
16416N/A * @{
16416N/A */
16416N/A
16416N/A/** AVL key type. */
16416N/Atypedef uint32_t AVLU32KEY;
16416N/A
16416N/A/** AVL Core node. */
16416N/Atypedef struct _AVLU32NodeCore
16416N/A{
16416N/A AVLU32KEY Key; /**< Key value. */
16416N/A struct _AVLU32NodeCore *pLeft; /**< Pointer to left leaf node. */
16416N/A struct _AVLU32NodeCore *pRight; /**< Pointer to right leaf node. */
16416N/A unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
16416N/A} AVLU32NODECORE, *PAVLU32NODECORE, **PPAVLU32NODECORE;
16416N/A
16416N/A/** Callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
16416N/Atypedef DECLCALLBACK(int) AVLU32CALLBACK(PAVLU32NODECORE, void*);
16416N/A/** Pointer to callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
16416N/Atypedef AVLU32CALLBACK *PAVLU32CALLBACK;
16416N/A
16416N/A
16416N/A/*
16416N/A * Functions.
16416N/A */
16416N/ARTDECL(bool) RTAvlU32Insert(PPAVLU32NODECORE ppTree, PAVLU32NODECORE pNode);
16416N/ARTDECL(PAVLU32NODECORE) RTAvlU32Remove(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
16416N/ARTDECL(PAVLU32NODECORE) RTAvlU32Get(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
16416N/ARTDECL(PAVLU32NODECORE) RTAvlU32GetBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
16416N/ARTDECL(PAVLU32NODECORE) RTAvlU32RemoveBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
16416N/ARTDECL(int) RTAvlU32DoWithAll(PPAVLU32NODECORE ppTree, int fFromLeft, PAVLU32CALLBACK pfnCallBack, void *pvParam);
16416N/ARTDECL(int) RTAvlU32Destroy(PPAVLU32NODECORE pTree, PAVLU32CALLBACK pfnCallBack, void *pvParam);
16416N/A
16416N/A/** @} */
16416N/A
16416N/A
16416N/A
16416N/A/** AVL tree of RTGCPHYSes - using relative offsets internally.
16416N/A * @{
16416N/A */
16416N/A
16416N/A/**
16416N/A * AVL 'pointer' type for the relative offset pointer scheme.
16416N/A */
16416N/Atypedef int32_t AVLOGCPHYS;
16416N/A
16416N/A/**
16416N/A * AVL Core node.
16416N/A */
16416N/Atypedef struct _AVLOGCPhysNodeCore
16416N/A{
16416N/A /** Key value. */
16416N/A RTGCPHYS Key;
16416N/A /** Offset to the left leaf node, relative to this field. */
16416N/A AVLOGCPHYS pLeft;
16416N/A /** Offset to the right leaf node, relative to this field. */
16416N/A AVLOGCPHYS pRight;
16416N/A /** Height of this tree: max(height(left), height(right)) + 1 */
16416N/A unsigned char uchHeight;
16416N/A} AVLOGCPHYSNODECORE, *PAVLOGCPHYSNODECORE;
16416N/A
16416N/A/** A offset base tree with uint32_t keys. */
16416N/Atypedef AVLOGCPHYS AVLOGCPHYSTREE;
16416N/A/** Pointer to a offset base tree with uint32_t keys. */
16416N/Atypedef AVLOGCPHYSTREE *PAVLOGCPHYSTREE;
16416N/A
16416N/A/** Pointer to an internal tree pointer.
16416N/A * In this case it's a pointer to a relative offset. */
16416N/Atypedef AVLOGCPHYSTREE *PPAVLOGCPHYSNODECORE;
16416N/A
16416N/A/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
16416N/Atypedef DECLCALLBACK(int) AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
16416N/A/** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
16416N/Atypedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;
16416N/A
16416N/ARTDECL(bool) RTAvloGCPhysInsert(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSNODECORE pNode);
16416N/ARTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemove(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
16416N/ARTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGet(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
16416N/ARTDECL(int) RTAvloGCPhysDoWithAll(PAVLOGCPHYSTREE pTree, int fFromLeft, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
16416N/ARTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGetBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
16416N/ARTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemoveBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
16416N/ARTDECL(int) RTAvloGCPhysDestroy(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
16416N/A
16416N/A/** @} */
16416N/A
16416N/A
16416N/A/** AVL tree of RTGCPHYS ranges - using relative offsets internally.
16416N/A * @{
16416N/A */
16416N/A
16416N/A/**
16416N/A * AVL 'pointer' type for the relative offset pointer scheme.
16416N/A */
16416N/Atypedef int32_t AVLROGCPHYS;
16416N/A
16416N/A/**
16416N/A * AVL Core node.
16416N/A */
16416N/Atypedef struct _AVLROGCPhysNodeCore
16416N/A{
16416N/A /** First key value in the range (inclusive). */
16416N/A RTGCPHYS Key;
16416N/A /** Last key value in the range (inclusive). */
16416N/A RTGCPHYS KeyLast;
16416N/A /** Offset to the left leaf node, relative to this field. */
16416N/A AVLROGCPHYS pLeft;
16416N/A /** Offset to the right leaf node, relative to this field. */
16416N/A AVLROGCPHYS pRight;
16416N/A /** Height of this tree: max(height(left), height(right)) + 1 */
16416N/A unsigned char uchHeight;
16416N/A} AVLROGCPHYSNODECORE, *PAVLROGCPHYSNODECORE;
16416N/A
16416N/A/** A offset base tree with uint32_t keys. */
16416N/Atypedef AVLROGCPHYS AVLROGCPHYSTREE;
16416N/A/** Pointer to a offset base tree with uint32_t keys. */
16416N/Atypedef AVLROGCPHYSTREE *PAVLROGCPHYSTREE;
16416N/A
16416N/A/** Pointer to an internal tree pointer.
16416N/A * In this case it's a pointer to a relative offset. */
16416N/Atypedef AVLROGCPHYSTREE *PPAVLROGCPHYSNODECORE;
16416N/A
16416N/A/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
16416N/Atypedef DECLCALLBACK(int) AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
16416N/A/** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
16416N/Atypedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;
16416N/A
16416N/ARTDECL(bool) RTAvlroGCPhysInsert(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSNODECORE pNode);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetBestFit(PAVLROGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
RTDECL(int) RTAvlroGCPhysDoWithAll(PAVLROGCPHYSTREE pTree, int fFromLeft, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
RTDECL(int) RTAvlroGCPhysDestroy(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRoot(PAVLROGCPHYSTREE pTree);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetLeft(PAVLROGCPHYSNODECORE pNode);
RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRight(PAVLROGCPHYSNODECORE pNode);
/** @} */
/** AVL tree of RTGCPTRs.
* @{
*/
/**
* AVL Core node.
*/
typedef struct _AVLGCPtrNodeCore
{
/** Key value. */
RTGCPTR Key;
/** Pointer to the left node. */
struct _AVLGCPtrNodeCore *pLeft;
/** Pointer to the right node. */
struct _AVLGCPtrNodeCore *pRight;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLGCPTRNODECORE, *PAVLGCPTRNODECORE, **PPAVLGCPTRNODECORE;
/** A tree of RTGCPTR keys. */
typedef PAVLGCPTRNODECORE AVLGCPTRTREE;
/** Pointer to a tree of RTGCPTR keys. */
typedef PPAVLGCPTRNODECORE PAVLGCPTRTREE;
/** Callback function for RTAvlroGCPtrDoWithAll(). */
typedef DECLCALLBACK(int) AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPtrDoWithAll(). */
typedef AVLGCPTRCALLBACK *PAVLGCPTRCALLBACK;
RTDECL(bool) RTAvlGCPtrInsert(PAVLGCPTRTREE pTree, PAVLGCPTRNODECORE pNode);
RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemove(PAVLGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGet(PAVLGCPTRTREE pTree, RTGCPTR Key);
RTDECL(int) RTAvlGCPtrDoWithAll(PAVLGCPTRTREE pTree, int fFromLeft, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGetBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemoveBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(int) RTAvlGCPtrDestroy(PAVLGCPTRTREE pTree, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** AVL tree of RTGCPTRs - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLOGCPTR;
/**
* AVL Core node.
*/
typedef struct _AVLOGCPtrNodeCore
{
/** Key value. */
RTGCPTR Key;
/** Offset to the left leaf node, relative to this field. */
AVLOGCPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLOGCPTR pRight;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLOGCPTRNODECORE, *PAVLOGCPTRNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLOGCPTR AVLOGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLOGCPTRTREE *PAVLOGCPTRTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLOGCPTRTREE *PPAVLOGCPTRNODECORE;
/** Callback function for RTAvlroGCPtrDoWithAll(). */
typedef DECLCALLBACK(int) AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPtrDoWithAll(). */
typedef AVLOGCPTRCALLBACK *PAVLOGCPTRCALLBACK;
RTDECL(bool) RTAvloGCPtrInsert(PAVLOGCPTRTREE pTree, PAVLOGCPTRNODECORE pNode);
RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemove(PAVLOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGet(PAVLOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(int) RTAvloGCPtrDoWithAll(PAVLOGCPTRTREE pTree, int fFromLeft, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGetBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemoveBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(int) RTAvloGCPtrDestroy(PAVLOGCPTRTREE pTree, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** AVL tree of RTGCPTR ranges - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLROGCPTR;
/**
* AVL Core node.
*/
typedef struct _AVLROGCPtrNodeCore
{
/** First key value in the range (inclusive). */
RTGCPTR Key;
/** Last key value in the range (inclusive). */
RTGCPTR KeyLast;
/** Offset to the left leaf node, relative to this field. */
AVLROGCPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLROGCPTR pRight;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLROGCPTRNODECORE, *PAVLROGCPTRNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLROGCPTR AVLROGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLROGCPTRTREE *PAVLROGCPTRTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLROGCPTRTREE *PPAVLROGCPTRNODECORE;
/** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
typedef DECLCALLBACK(int) AVLROGCPTRCALLBACK(PAVLROGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
typedef AVLROGCPTRCALLBACK *PAVLROGCPTRCALLBACK;
RTDECL(bool) RTAvlroGCPtrInsert(PAVLROGCPTRTREE pTree, PAVLROGCPTRNODECORE pNode);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetBestFit(PAVLROGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
RTDECL(int) RTAvlroGCPtrDoWithAll(PAVLROGCPTRTREE pTree, int fFromLeft, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(int) RTAvlroGCPtrDestroy(PAVLROGCPTRTREE pTree, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRoot(PAVLROGCPTRTREE pTree);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetLeft(PAVLROGCPTRNODECORE pNode);
RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRight(PAVLROGCPTRNODECORE pNode);
/** @} */
/** AVL tree of RTGCPTR ranges (overlapping supported) - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLROOGCPTR;
/**
* AVL Core node.
*/
typedef struct _AVLROOGCPtrNodeCore
{
/** First key value in the range (inclusive). */
RTGCPTR Key;
/** Last key value in the range (inclusive). */
RTGCPTR KeyLast;
/** Offset to the left leaf node, relative to this field. */
AVLROOGCPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLROOGCPTR pRight;
/** Pointer to the list of string with the same key. Don't touch. */
AVLROOGCPTR pList;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLROOGCPTRNODECORE, *PAVLROOGCPTRNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLROOGCPTR AVLROOGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLROOGCPTRTREE *PAVLROOGCPTRTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLROOGCPTRTREE *PPAVLROOGCPTRNODECORE;
/** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
typedef DECLCALLBACK(int) AVLROOGCPTRCALLBACK(PAVLROOGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
typedef AVLROOGCPTRCALLBACK *PAVLROOGCPTRCALLBACK;
RTDECL(bool) RTAvlrooGCPtrInsert(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRNODECORE pNode);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetBestFit(PAVLROOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
RTDECL(int) RTAvlrooGCPtrDoWithAll(PAVLROOGCPTRTREE pTree, int fFromLeft, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(int) RTAvlrooGCPtrDestroy(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRoot(PAVLROOGCPTRTREE pTree);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetLeft(PAVLROOGCPTRNODECORE pNode);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRight(PAVLROOGCPTRNODECORE pNode);
RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetNextEqual(PAVLROOGCPTRNODECORE pNode);
/** @} */
/** AVL tree of RTHCPHYSes - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLOHCPHYS;
/**
* AVL Core node.
*/
typedef struct _AVLOHCPhysNodeCore
{
/** Key value. */
RTHCPHYS Key;
/** Offset to the left leaf node, relative to this field. */
AVLOHCPHYS pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLOHCPHYS pRight;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLOHCPHYSNODECORE, *PAVLOHCPHYSNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLOHCPHYS AVLOHCPHYSTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLOHCPHYSTREE *PAVLOHCPHYSTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLOHCPHYSTREE *PPAVLOHCPHYSNODECORE;
/** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
typedef DECLCALLBACK(int) AVLOHCPHYSCALLBACK(PAVLOHCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
typedef AVLOHCPHYSCALLBACK *PAVLOHCPHYSCALLBACK;
RTDECL(bool) RTAvloHCPhysInsert(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSNODECORE pNode);
RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemove(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGet(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
RTDECL(int) RTAvloHCPhysDoWithAll(PAVLOHCPHYSTREE pTree, int fFromLeft, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGetBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemoveBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
RTDECL(int) RTAvloHCPhysDestroy(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** AVL tree of RTIOPORTs - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLOIOPORTPTR;
/**
* AVL Core node.
*/
typedef struct _AVLOIOPortNodeCore
{
/** Offset to the left leaf node, relative to this field. */
AVLOIOPORTPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLOIOPORTPTR pRight;
/** Key value. */
RTIOPORT Key;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLOIOPORTNODECORE, *PAVLOIOPORTNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLOIOPORTPTR AVLOIOPORTTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLOIOPORTTREE *PAVLOIOPORTTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLOIOPORTTREE *PPAVLOIOPORTNODECORE;
/** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
typedef DECLCALLBACK(int) AVLOIOPORTCALLBACK(PAVLOIOPORTNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
typedef AVLOIOPORTCALLBACK *PAVLOIOPORTCALLBACK;
RTDECL(bool) RTAvloIOPortInsert(PAVLOIOPORTTREE pTree, PAVLOIOPORTNODECORE pNode);
RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemove(PAVLOIOPORTTREE pTree, RTIOPORT Key);
RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGet(PAVLOIOPORTTREE pTree, RTIOPORT Key);
RTDECL(int) RTAvloIOPortDoWithAll(PAVLOIOPORTTREE pTree, int fFromLeft, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
RTDECL(int) RTAvloIOPortDestroy(PAVLOIOPORTTREE pTree, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** AVL tree of RTIOPORT ranges - using relative offsets internally.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef int32_t AVLROIOPORTPTR;
/**
* AVL Core node.
*/
typedef struct _AVLROIOPortNodeCore
{
/** First key value in the range (inclusive). */
RTIOPORT Key;
/** Last key value in the range (inclusive). */
RTIOPORT KeyLast;
/** Offset to the left leaf node, relative to this field. */
AVLROIOPORTPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLROIOPORTPTR pRight;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLROIOPORTNODECORE, *PAVLROIOPORTNODECORE;
/** A offset base tree with uint32_t keys. */
typedef AVLROIOPORTPTR AVLROIOPORTTREE;
/** Pointer to a offset base tree with uint32_t keys. */
typedef AVLROIOPORTTREE *PAVLROIOPORTTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLROIOPORTTREE *PPAVLROIOPORTNODECORE;
/** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
typedef DECLCALLBACK(int) AVLROIOPORTCALLBACK(PAVLROIOPORTNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
typedef AVLROIOPORTCALLBACK *PAVLROIOPORTCALLBACK;
RTDECL(bool) RTAvlroIOPortInsert(PAVLROIOPORTTREE pTree, PAVLROIOPORTNODECORE pNode);
RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
RTDECL(int) RTAvlroIOPortDoWithAll(PAVLROIOPORTTREE pTree, int fFromLeft, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
RTDECL(int) RTAvlroIOPortDestroy(PAVLROIOPORTTREE pTree, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** AVL tree of RTHCPHYSes.
* @{
*/
/**
* AVL 'pointer' type for the relative offset pointer scheme.
*/
typedef struct _AVLHCPhysNodeCore *AVLHCPHYSPTR;
/**
* AVL Core node.
*/
typedef struct _AVLHCPhysNodeCore
{
/** Offset to the left leaf node, relative to this field. */
AVLHCPHYSPTR pLeft;
/** Offset to the right leaf node, relative to this field. */
AVLHCPHYSPTR pRight;
/** Key value. */
RTHCPHYS Key;
/** Height of this tree: max(height(left), height(right)) + 1 */
unsigned char uchHeight;
} AVLHCPHYSNODECORE, *PAVLHCPHYSNODECORE;
/** A offset base tree with RTHCPHYS keys. */
typedef AVLHCPHYSPTR AVLHCPHYSTREE;
/** Pointer to a offset base tree with RTHCPHYS keys. */
typedef AVLHCPHYSTREE *PAVLHCPHYSTREE;
/** Pointer to an internal tree pointer.
* In this case it's a pointer to a relative offset. */
typedef AVLHCPHYSTREE *PPAVLHCPHYSNODECORE;
/** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
typedef DECLCALLBACK(int) AVLHCPHYSCALLBACK(PAVLHCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
typedef AVLHCPHYSCALLBACK *PAVLHCPHYSCALLBACK;
RTDECL(bool) RTAvlHCPhysInsert(PAVLHCPHYSTREE pTree, PAVLHCPHYSNODECORE pNode);
RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemove(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGet(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
RTDECL(int) RTAvlHCPhysDoWithAll(PAVLHCPHYSTREE pTree, int fFromLeft, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGetBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemoveBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
RTDECL(int) RTAvlHCPhysDestroy(PAVLHCPHYSTREE pTree, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
/** @} */
/** @} */
__END_DECLS
#endif