Btree Functions

:Associate with "Btree Functions" More...

Typedefs

typedef int(* BTreeDumpFunc )(void *data, INT32 *tagnum, void *username)
typedef int(* BTreeTestFunc )(void *, void *, void *)

Functions

GEOMLIBEXPORT void * BTreeAlloc (int numitems, int datasize, BTreeTestFunc testfunc, void *userdata)
GEOMLIBEXPORT int BTreeClear (void *item)
GEOMLIBEXPORT int BTreeDump (void *tree, BTreeDumpFunc, void *userdata)
GEOMLIBEXPORT int BTreeDumpT (void *tree, BTreeDumpFunc, void *userdata)
GEOMLIBEXPORT INT32 BTreeFindKey (void *tree, void *data, INT32 tagnum, int *add)
GEOMLIBEXPORT int BTreeFree (void *tree)
GEOMLIBEXPORT int BTreeNewFunc (void *tree, BTreeTestFunc, void *userdata)
GEOMLIBEXPORT INT32 BTreeSearchKey (void *tree, void *data)
GEOMLIBEXPORT void BTreeSetTestFunc (void *btree, BTreeTestFunc Test, void *userdata, bool TestFuncIsConst)

Detailed Description

:Associate with "Btree Functions"


Typedef Documentation

typedef int(* BTreeDumpFunc)(void *data,INT32 *tagnum,void *username)
 

Callback used to return data.

Definition at line 76 of file btreefun.h.

typedef int(* BTreeTestFunc)(void *, void *, void *)
 

Tree comparison function used in searching/adding.

Returns:
>, ==, < 0.

Definition at line 69 of file btreefun.h.


Function Documentation

GEOMLIBEXPORT void* BTreeAlloc int  numitems,
int  datasize,
BTreeTestFunc  testfunc,
void *  userdata
 

Allocate a "balanced tree".

Returns:
Handle to tree instance.
Note. At the current time, it is assumed that the test function may modify the data, forcing the tree to do more work that it should have to. You should not rely on this assumption, as it was an obscure, undocumented side effect and likely to change some day. Instead, you should call BTreeSetTestFunc() and tell it if your test function can modify the data.
Parameters:
numitems  Number of items to store per node
datasize  Size of data to tree in bytes
testfunc  Comparison function used in searching/adding
userdata  Data passed to comparison function

GEOMLIBEXPORT int BTreeClear void *  item  ) 
 

Clears item from "balanced tree".

Parameters:
item  Item to be cleared from tree

GEOMLIBEXPORT int BTreeDump void *  tree,
BTreeDumpFunc  ,
void *  userdata
 

Dump a "balanced tree" in "random" order.

NOTE: This function transverses the tree as it is stored, no order is at all guaranteed!

Parameters:
tree  Handle to tree instance
userdata  User data passed to Dump()

GEOMLIBEXPORT int BTreeDumpT void *  tree,
BTreeDumpFunc  ,
void *  userdata
 

Dump a "balanced tree" in "traversal" order.

NOTE: This function transverses the tree and dumps the data in the order that the comparison function (see BTreeAlloc()) stipulated.

Parameters:
tree  Handle to tree instance
userdata  User data passed to Dump()

GEOMLIBEXPORT INT32 BTreeFindKey void *  tree,
void *  data,
INT32  tagnum,
int *  add
 

Search "balanced tree" for a specified key, add if no match found.

Returns:
tag number assigned to the data if (>=0), else error
Parameters:
tree  Handle to tree instance
data  Data to find and add if necessary
tagnum  Number to tag data with
add  Set if data was added to tree

GEOMLIBEXPORT int BTreeFree void *  tree  ) 
 

Free a "balanced tree".

Parameters:
tree  Handle to tree instance

GEOMLIBEXPORT int BTreeNewFunc void *  tree,
BTreeTestFunc  ,
void *  userdata
 

Change test function for a "balanced tree".

Parameters:
tree  Handle to tree instance
userdata  Data passed to comparison function

GEOMLIBEXPORT INT32 BTreeSearchKey void *  tree,
void *  data
 

Search "balanced tree" for a specified key.

Returns:
-1 = Not found, < -1 Error, else the tag number associated with the data. See BTreeFindKey().
Parameters:
tree  Handle to tree instance
data  Data to find if exists

GEOMLIBEXPORT void BTreeSetTestFunc void *  btree,
BTreeTestFunc  Test,
void *  userdata,
bool  TestFuncIsConst
 

Change test function for a "balanced tree".

This is similar to BTreeNewFunc, but allows you to tell the BTree that the function won't modify the data it's passed. The default behaviour for btrees is to assume that the test function can modify the data passed.


Generated on Wed May 31 15:29:21 2006 for TNTsdk by  doxygen 1.3.8-20040913