Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

avl.h

Go to the documentation of this file.
/** @file
 * innotek Portable Runtime - AVL Trees.
 */

/*
 * Copyright (C) 1999-2003 knut st. osmundsen <bird-src-spam@anduin.net>
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation,
 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
 * distribution. VirtualBox OSE is distributed in the hope that it will
 * be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef ___iprt_avl_h
#define ___iprt_avl_h

#include <iprt/cdefs.h>
#include <iprt/types.h>

__BEGIN_DECLS

/** @defgroup grp_rt_avl    RTAvl - AVL Trees
 * @ingroup grp_rt
 * @{
 */


/** AVL tree of void pointers.
 * @{
 */

/**
 * AVL key type
 */
00038 typedef void *  AVLPVKEY;

/**
 * AVL Core node.
 */
00043 typedef struct _AVLPVNodeCore
{
    AVLPVKEY                Key;        /** Key value. */
00046     struct _AVLPVNodeCore  *pLeft;      /** Pointer to left leaf node. */
00047     struct _AVLPVNodeCore  *pRight;     /** Pointer to right leaf node. */
00048     unsigned char           uchHeight;  /** Height of this tree: max(height(left), height(right)) + 1 */
} AVLPVNODECORE, *PAVLPVNODECORE, **PPAVLPVNODECORE;

/** A tree with void pointer keys. */
00052 typedef PAVLPVNODECORE     AVLPVTREE;
/** Pointer to a tree with void pointer keys. */
00054 typedef PPAVLPVNODECORE    PAVLPVTREE;

/** Callback function for AVLPVDoWithAll(). */
00057 typedef DECLCALLBACK(int) AVLPVCALLBACK(PAVLPVNODECORE, void *);
/** Pointer to callback function for AVLPVDoWithAll(). */
typedef AVLPVCALLBACK *PAVLPVCALLBACK;

/*
 * Functions.
 */
RTDECL(bool)            RTAvlPVInsert(PAVLPVTREE ppTree, PAVLPVNODECORE pNode);
RTDECL(PAVLPVNODECORE)  RTAvlPVRemove(PAVLPVTREE ppTree, AVLPVKEY Key);
RTDECL(PAVLPVNODECORE)  RTAvlPVGet(PAVLPVTREE ppTree, AVLPVKEY Key);
RTDECL(PAVLPVNODECORE)  RTAvlPVGetBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
RTDECL(PAVLPVNODECORE)  RTAvlPVRemoveBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
RTDECL(int)             RTAvlPVDoWithAll(PAVLPVTREE ppTree, int fFromLeft, PAVLPVCALLBACK pfnCallBack, void *pvParam);
RTDECL(int)             RTAvlPVDestroy(PAVLPVTREE ppTree, PAVLPVCALLBACK pfnCallBack, void *pvParam);

/** @} */


/** AVL tree of unsigned long.
 * @{
 */

/**
 * AVL key type
 */
00082 typedef unsigned long   AVLULKEY;

/**
 * AVL Core node.
 */
00087 typedef struct _AVLULNodeCore
{
    AVLULKEY                Key;        /** Key value. */
00090     struct _AVLULNodeCore  *pLeft;      /** Pointer to left leaf node. */
00091     struct _AVLULNodeCore  *pRight;     /** Pointer to right leaf node. */
00092     unsigned char           uchHeight;  /** Height of this tree: max(height(left), height(right)) + 1 */
} AVLULNODECORE, *PAVLULNODECORE, **PPAVLULNODECORE;


/** Callback function for AVLULDoWithAll(). */
00097 typedef DECLCALLBACK(int) AVLULCALLBACK(PAVLULNODECORE, void*);
/** Pointer to callback function for AVLULDoWithAll(). */
typedef AVLULCALLBACK *PAVLULCALLBACK;


/*
 * Functions.
 */
RTDECL(bool)            RTAvlULInsert(PPAVLULNODECORE ppTree, PAVLULNODECORE pNode);
RTDECL(PAVLULNODECORE)  RTAvlULRemove(PPAVLULNODECORE ppTree, AVLULKEY Key);
RTDECL(PAVLULNODECORE)  RTAvlULGet(PPAVLULNODECORE ppTree, AVLULKEY Key);
RTDECL(PAVLULNODECORE)  RTAvlULGetBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
RTDECL(PAVLULNODECORE)  RTAvlULRemoveBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
RTDECL(int)             RTAvlULDoWithAll(PPAVLULNODECORE ppTree, int fFromLeft, PAVLULCALLBACK pfnCallBack, void *pvParam);

/** @} */



/** AVL tree of uint32_t
 * @{
 */

/** AVL key type. */
00121 typedef uint32_t    AVLU32KEY;

/** AVL Core node. */
00124 typedef struct _AVLU32NodeCore
{
00126     AVLU32KEY               Key;        /**< Key value. */
00127     struct _AVLU32NodeCore *pLeft;      /**< Pointer to left leaf node. */
00128     struct _AVLU32NodeCore *pRight;     /**< Pointer to right leaf node. */
00129     unsigned char           uchHeight;  /**< Height of this tree: max(height(left), height(right)) + 1 */
} AVLU32NODECORE, *PAVLU32NODECORE, **PPAVLU32NODECORE;

/** Callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
00133 typedef DECLCALLBACK(int) AVLU32CALLBACK(PAVLU32NODECORE, void*);
/** Pointer to callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
typedef AVLU32CALLBACK *PAVLU32CALLBACK;


/*
 * Functions.
 */
RTDECL(bool)            RTAvlU32Insert(PPAVLU32NODECORE ppTree, PAVLU32NODECORE pNode);
RTDECL(PAVLU32NODECORE) RTAvlU32Remove(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
RTDECL(PAVLU32NODECORE) RTAvlU32Get(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
RTDECL(PAVLU32NODECORE) RTAvlU32GetBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
RTDECL(PAVLU32NODECORE) RTAvlU32RemoveBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
RTDECL(int)             RTAvlU32DoWithAll(PPAVLU32NODECORE ppTree, int fFromLeft, PAVLU32CALLBACK pfnCallBack, void *pvParam);
RTDECL(int)             RTAvlU32Destroy(PPAVLU32NODECORE pTree, PAVLU32CALLBACK pfnCallBack, void *pvParam);

/** @} */



/** AVL tree of RTGCPHYSes - using relative offsets internally.
 * @{
 */

/**
 * AVL 'pointer' type for the relative offset pointer scheme.
 */
00160 typedef int32_t     AVLOGCPHYS;

/**
 * AVL Core node.
 */
00165 typedef struct _AVLOGCPhysNodeCore
{
    /** Key value. */
00168     RTGCPHYS            Key;
    /** Offset to the left leaf node, relative to this field. */
00170     AVLOGCPHYS          pLeft;
    /** Offset to the right leaf node, relative to this field. */
00172     AVLOGCPHYS          pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00174     unsigned char       uchHeight;
} AVLOGCPHYSNODECORE, *PAVLOGCPHYSNODECORE;

/** A offset base tree with uint32_t keys. */
00178 typedef AVLOGCPHYS         AVLOGCPHYSTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00180 typedef AVLOGCPHYSTREE    *PAVLOGCPHYSTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00184 typedef AVLOGCPHYSTREE    *PPAVLOGCPHYSNODECORE;

/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
typedef DECLCALLBACK(int)   AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
00189 typedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;

RTDECL(bool)                    RTAvloGCPhysInsert(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSNODECORE pNode);
RTDECL(PAVLOGCPHYSNODECORE)     RTAvloGCPhysRemove(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(PAVLOGCPHYSNODECORE)     RTAvloGCPhysGet(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
RTDECL(int)                     RTAvloGCPhysDoWithAll(PAVLOGCPHYSTREE pTree, int fFromLeft, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLOGCPHYSNODECORE)     RTAvloGCPhysGetBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
RTDECL(PAVLOGCPHYSNODECORE)     RTAvloGCPhysRemoveBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
RTDECL(int)                     RTAvloGCPhysDestroy(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);

/** @} */


/** AVL tree of RTGCPHYS ranges - using relative offsets internally.
 * @{
 */

/**
 * AVL 'pointer' type for the relative offset pointer scheme.
 */
00209 typedef int32_t     AVLROGCPHYS;

/**
 * AVL Core node.
 */
00214 typedef struct _AVLROGCPhysNodeCore
{
    /** First key value in the range (inclusive). */
00217     RTGCPHYS            Key;
    /** Last key value in the range (inclusive). */
00219     RTGCPHYS            KeyLast;
    /** Offset to the left leaf node, relative to this field. */
00221     AVLROGCPHYS         pLeft;
    /** Offset to the right leaf node, relative to this field. */
00223     AVLROGCPHYS         pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00225     unsigned char       uchHeight;
} AVLROGCPHYSNODECORE, *PAVLROGCPHYSNODECORE;

/** A offset base tree with uint32_t keys. */
00229 typedef AVLROGCPHYS         AVLROGCPHYSTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00231 typedef AVLROGCPHYSTREE    *PAVLROGCPHYSTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00235 typedef AVLROGCPHYSTREE    *PPAVLROGCPHYSNODECORE;

/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
typedef DECLCALLBACK(int)   AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
00240 typedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;

RTDECL(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.
 */
00264 typedef struct _AVLGCPtrNodeCore
{
    /** Key value. */
00267     RTGCPTR             Key;
    /** Pointer to the left node. */
00269     struct _AVLGCPtrNodeCore *pLeft;
    /** Pointer to the right node. */
00271     struct _AVLGCPtrNodeCore *pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00273     unsigned char       uchHeight;
} AVLGCPTRNODECORE, *PAVLGCPTRNODECORE, **PPAVLGCPTRNODECORE;

/** A tree of RTGCPTR keys. */
00277 typedef PAVLGCPTRNODECORE     AVLGCPTRTREE;
/** Pointer to a tree of RTGCPTR keys. */
00279 typedef PPAVLGCPTRNODECORE    PAVLGCPTRTREE;

/** Callback function for RTAvlGCPtrDoWithAll(). */
typedef DECLCALLBACK(int)   AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlGCPtrDoWithAll(). */
00284 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.
 */
00304 typedef int32_t     AVLOGCPTR;

/**
 * AVL Core node.
 */
00309 typedef struct _AVLOGCPtrNodeCore
{
    /** Key value. */
00312     RTGCPTR             Key;
    /** Offset to the left leaf node, relative to this field. */
00314     AVLOGCPTR           pLeft;
    /** Offset to the right leaf node, relative to this field. */
00316     AVLOGCPTR           pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00318     unsigned char       uchHeight;
} AVLOGCPTRNODECORE, *PAVLOGCPTRNODECORE;

/** A offset base tree with uint32_t keys. */
00322 typedef AVLOGCPTR         AVLOGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00324 typedef AVLOGCPTRTREE    *PAVLOGCPTRTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00328 typedef AVLOGCPTRTREE    *PPAVLOGCPTRNODECORE;

/** Callback function for RTAvloGCPtrDoWithAll(). */
typedef DECLCALLBACK(int)   AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloGCPtrDoWithAll(). */
00333 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.
 * @{
 */

/**
 * AVL Core node.
 */
00353 typedef struct _AVLRGCPtrNodeCore
{
    /** First key value in the range (inclusive). */
00356     RTGCPTR             Key;
    /** Last key value in the range (inclusive). */
00358     RTGCPTR             KeyLast;
    /** Offset to the left leaf node, relative to this field. */
00360     struct _AVLRGCPtrNodeCore  *pLeft;
    /** Offset to the right leaf node, relative to this field. */
00362     struct _AVLRGCPtrNodeCore  *pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00364     unsigned char       uchHeight;
} AVLRGCPTRNODECORE, *PAVLRGCPTRNODECORE;

/** A offset base tree with RTGCPTR keys. */
00368 typedef PAVLRGCPTRNODECORE AVLRGCPTRTREE;
/** Pointer to a offset base tree with RTGCPTR keys. */
00370 typedef AVLRGCPTRTREE    *PAVLRGCPTRTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00374 typedef AVLRGCPTRTREE    *PPAVLRGCPTRNODECORE;

/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
typedef DECLCALLBACK(int)   AVLRGCPTRCALLBACK(PAVLRGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
00379 typedef AVLRGCPTRCALLBACK *PAVLRGCPTRCALLBACK;

RTDECL(bool)                   RTAvlrGCPtrInsert(       PAVLRGCPTRTREE pTree, PAVLRGCPTRNODECORE pNode);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrRemove(       PAVLRGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrGet(          PAVLRGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrGetBestFit(   PAVLRGCPTRTREE pTree, RTGCPTR Key, bool fAbove);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrRangeGet(     PAVLRGCPTRTREE pTree, RTGCPTR Key);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrRangeRemove(  PAVLRGCPTRTREE pTree, RTGCPTR Key);
RTDECL(int)                    RTAvlrGCPtrDoWithAll(    PAVLRGCPTRTREE pTree, int fFromLeft, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(int)                    RTAvlrGCPtrDestroy(      PAVLRGCPTRTREE pTree, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrGetRoot(      PAVLRGCPTRTREE pTree);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrGetLeft(      PAVLRGCPTRNODECORE pNode);
RTDECL(PAVLRGCPTRNODECORE)     RTAvlrGCPtrGetRight(     PAVLRGCPTRNODECORE pNode);

/** @} */


/** AVL tree of RTGCPTR ranges - using relative offsets internally.
 * @{
 */

/**
 * AVL 'pointer' type for the relative offset pointer scheme.
 */
00403 typedef int32_t     AVLROGCPTR;

/**
 * AVL Core node.
 */
00408 typedef struct _AVLROGCPtrNodeCore
{
    /** First key value in the range (inclusive). */
00411     RTGCPTR             Key;
    /** Last key value in the range (inclusive). */
00413     RTGCPTR             KeyLast;
    /** Offset to the left leaf node, relative to this field. */
00415     AVLROGCPTR          pLeft;
    /** Offset to the right leaf node, relative to this field. */
00417     AVLROGCPTR          pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00419     unsigned char       uchHeight;
} AVLROGCPTRNODECORE, *PAVLROGCPTRNODECORE;

/** A offset base tree with uint32_t keys. */
00423 typedef AVLROGCPTR         AVLROGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00425 typedef AVLROGCPTRTREE    *PAVLROGCPTRTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00429 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(). */
00434 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.
 */
00458 typedef int32_t     AVLROOGCPTR;

/**
 * AVL Core node.
 */
00463 typedef struct _AVLROOGCPtrNodeCore
{
    /** First key value in the range (inclusive). */
00466     RTGCPTR             Key;
    /** Last key value in the range (inclusive). */
00468     RTGCPTR             KeyLast;
    /** Offset to the left leaf node, relative to this field. */
00470     AVLROOGCPTR         pLeft;
    /** Offset to the right leaf node, relative to this field. */
00472     AVLROOGCPTR         pRight;
    /** Pointer to the list of string with the same key. Don't touch. */
00474     AVLROOGCPTR         pList;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00476     unsigned char       uchHeight;
} AVLROOGCPTRNODECORE, *PAVLROOGCPTRNODECORE;

/** A offset base tree with uint32_t keys. */
00480 typedef AVLROOGCPTR         AVLROOGCPTRTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00482 typedef AVLROOGCPTRTREE    *PAVLROOGCPTRTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00486 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(). */
00491 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.
 */
00516 typedef int32_t     AVLOHCPHYS;

/**
 * AVL Core node.
 */
00521 typedef struct _AVLOHCPhysNodeCore
{
    /** Key value. */
00524     RTHCPHYS            Key;
    /** Offset to the left leaf node, relative to this field. */
00526     AVLOHCPHYS          pLeft;
    /** Offset to the right leaf node, relative to this field. */
00528     AVLOHCPHYS          pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00530     unsigned char       uchHeight;
#if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
    unsigned char       Padding[7]; /**< Alignment padding. */
#endif 
} AVLOHCPHYSNODECORE, *PAVLOHCPHYSNODECORE;

/** A offset base tree with uint32_t keys. */
00537 typedef AVLOHCPHYS         AVLOHCPHYSTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00539 typedef AVLOHCPHYSTREE    *PAVLOHCPHYSTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00543 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(). */
00548 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.
 */
00569 typedef int32_t     AVLOIOPORTPTR;

/**
 * AVL Core node.
 */
00574 typedef struct _AVLOIOPortNodeCore
{
    /** Offset to the left leaf node, relative to this field. */
00577     AVLOIOPORTPTR       pLeft;
    /** Offset to the right leaf node, relative to this field. */
00579     AVLOIOPORTPTR       pRight;
    /** Key value. */
00581     RTIOPORT            Key;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00583     unsigned char       uchHeight;
} AVLOIOPORTNODECORE, *PAVLOIOPORTNODECORE;

/** A offset base tree with uint32_t keys. */
00587 typedef AVLOIOPORTPTR      AVLOIOPORTTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00589 typedef AVLOIOPORTTREE    *PAVLOIOPORTTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00593 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(). */
00598 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.
 */
00616 typedef int32_t     AVLROIOPORTPTR;

/**
 * AVL Core node.
 */
00621 typedef struct _AVLROIOPortNodeCore
{
    /** First key value in the range (inclusive). */
00624     RTIOPORT            Key;
    /** Last key value in the range (inclusive). */
00626     RTIOPORT            KeyLast;
    /** Offset to the left leaf node, relative to this field. */
00628     AVLROIOPORTPTR      pLeft;
    /** Offset to the right leaf node, relative to this field. */
00630     AVLROIOPORTPTR      pRight;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00632     unsigned char       uchHeight;
} AVLROIOPORTNODECORE, *PAVLROIOPORTNODECORE;

/** A offset base tree with uint32_t keys. */
00636 typedef AVLROIOPORTPTR      AVLROIOPORTTREE;
/** Pointer to a offset base tree with uint32_t keys. */
00638 typedef AVLROIOPORTTREE    *PAVLROIOPORTTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00642 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(). */
00647 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.
 */
00667 typedef struct _AVLHCPhysNodeCore  *AVLHCPHYSPTR;

/**
 * AVL Core node.
 */
00672 typedef struct _AVLHCPhysNodeCore
{
    /** Offset to the left leaf node, relative to this field. */
00675     AVLHCPHYSPTR        pLeft;
    /** Offset to the right leaf node, relative to this field. */
00677     AVLHCPHYSPTR        pRight;
    /** Key value. */
00679     RTHCPHYS            Key;
    /** Height of this tree: max(height(left), height(right)) + 1 */
00681     unsigned char       uchHeight;
} AVLHCPHYSNODECORE, *PAVLHCPHYSNODECORE;

/** A offset base tree with RTHCPHYS keys. */
00685 typedef AVLHCPHYSPTR      AVLHCPHYSTREE;
/** Pointer to a offset base tree with RTHCPHYS keys. */
00687 typedef AVLHCPHYSTREE    *PAVLHCPHYSTREE;

/** Pointer to an internal tree pointer.
 * In this case it's a pointer to a relative offset. */
00691 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(). */
00696 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


Generated by  Doxygen 1.6.0   Back to index