📄 rtree.h
字号:
* output : none
* return : Node ID of the added node on success
* Negative value on failure
************************************************************************/
int rtAddHead(
IN HRTREE rtH,
IN int parent,
IN RTElement elem);
/************************************************************************
* rtAddTail
* purpose: Add a new node as the last child of a parent
* input : rtH - Handle of the RTREE object
* parent - Parent's node ID
* elem - Element to add
* If given as NULL, an empty element is added
* output : none
* return : Node ID of the added node on success
* Negative value on failure
************************************************************************/
int rtAddTail(
IN HRTREE rtH,
IN int parent,
IN RTElement elem);
/************************************************************************
* rtAddBrother
* purpose: Add a new node as the closest (right) brother of a given node
* input : rtH - Handle of the RTREE object
* brother - Brother node we're joining to the right
* elem - Element to add
* If given as NULL, an empty element is added
* output : none
* return : Node ID of the added node on success
* Negative value on failure
************************************************************************/
int rtAddBrother(
IN HRTREE rtH,
IN int brother,
IN RTElement elem);
/************************************************************************
* rtAdd
* purpose: Iterative copy of a source subtree under a destination parent
* node as its last child.
* - The source and destination RTREE elements must have the same size
* - There should be enough room in the destination for the source
* subtree
* input : destH - Handle to destination RTREE
* destParentId - Destination parent node. We're going to add
* a new child to it (a last child)
* srcH - Handle to source RTREE
* srcRootId - The node ID of the source tree we're adding
* under the destination parent node.
* fadd - User's add function - called for every
* added node in the tree.
* If this function returns NULL, it is considered
* an error in the execution of rtAdd.
* can be set to NULL
* param - Context parameter to use on calls to fadd
* output : none
* return : Node ID of the added node on success
* Negative value on failure
************************************************************************/
int rtAdd(
IN HRTREE destH,
IN int destParentId,
IN HRTREE srcH,
IN int srcRootId,
IN RTEFunc fadd,
IN void* param);
/************************************************************************
* rtAdd
* purpose: Iterative copy of all the children of a source node under a
* destination parent node as its last children.
* - The source and destination RTREE elements must have the same size
* - There should be enough room in the destination for the source
* subtree
* input : destH - Handle to destination RTREE
* destParentId - Destination parent node. We're going to add
* a new child to it (a last child)
* srcH - Handle to source RTREE
* srcRootId - The node ID of the source tree whose children
* we're adding under the destination parent node.
* fadd - User's add function - called for every
* added node in the tree.
* If this function returns NULL, it is considered
* an error in the execution of rtAddChilds.
* can be set to NULL
* param - Context parameter to use on calls to fadd
* output : none
* return : Non-negative value on success
* Negative value on failure
************************************************************************/
int rtAddChilds(
IN HRTREE destH,
IN int destParentId,
IN HRTREE srcH,
IN int srcRootId,
IN RTEFunc fadd,
IN void* param);
/************************************************************************
* rtSet
* purpose: Copy a source sub-tree onto destParentId, deleting any previous
* content and nodes under destParentId
* - The source and destination RTREE elements must have the same size
* - There should be enough room in the destination for the source
* subtree
* input : destH - Handle to destination RTREE
* destParentId - Destination parent node. We're going to delete
* it and copy srcRootId onto it
* srcH - Handle to source RTREE
* srcRootId - The node ID of the source tree we'll copy
* fadd - User's add function - called for every
* added node in the tree.
* If this function returns NULL, it is considered
* an error in the execution of rtAddChilds.
* can be set to NULL
* fdelete - User's delete function - caled for every
* deleted node under destParentId, including destParentId
* param - Context parameter to use on calls to fadd and fdelete
* output : none
* return : Non-negative value on success
* Negative value on failure
************************************************************************/
int rtSet(
IN HRTREE destH,
IN int destParentId,
IN HRTREE srcH,
IN int srcRootId,
IN RTEFunc fadd,
IN RTEFunc fdelete,
IN void* param);
int /* RV_TRUE or negative value on failure */
rtMove(
/* move sub-tree to another sub-tree, NO restriction */
IN HRTREE rtH,
IN int destNodeId,
IN int srcRootId,
IN RvBool keepSrcRoot, /* true==> srcRoot node not deleted */
IN RTEFunc fdelete, /* user delete node function */
IN void *param /* for add and delete user functions */
);
int /* RV_TRUE or negative value on failure */
rtAdoptChild(
/* Child is adopted by its new family. new brother is a child of new parent. */
IN HRTREE rtH,
IN int adoptedChildId, /* child to be adopted by the new family */
IN int newParentId, /* parent of adopted child. -1: become root */
IN int newBrotherId /* previously born child (left brother). -1: first born */
);
int /* RV_TRUE or negative value on failure */
rtDeleteNode(
/* delete this node and update links (parent or brother) */
/* Must be a leaf (no childs) */
IN HRTREE rtH,
IN int location, /* this node id */
IN RTEFunc fdelete, /* delete function */
IN void *param
);
int /* RV_TRUE or negative value on failure */
rtDelete(
/* delete subtree from rootId. Iterative preorder deleting */
IN HRTREE rtH,
IN int rootId, /* subtree root id */
IN RTEFunc fdelete, /* delete function */
IN void *param
);
int /* RV_TRUE or negative value on failure */
rtDeleteChilds(
/* delete all child-sub-trees of rootId. Iterative preorder deleting */
IN HRTREE rtH,
IN int rootId, /* subtree root id */
IN RTEFunc fdelete, /* delete function */
IN void *param
);
int /* number of nodes in sub-tree */
rtTreeSize(
/* calc. num of nodes in subtree */
IN HRTREE rtH,
IN int rootId
);
int rtGetChild (HRTREE rtH, int parent, void *param, int index);
int rtFind (HRTREE rtH, int subTreeRoot, void *param, int index);
int rtCompare (HRTREE rtH, int subTreeRoot, void *param, int index, RTECompare compare);
int /* RV_TRUE or negative value on failure */
rtCompareTrees(
/* Compare between two trees.
The trees must be structure identical.
The compare function check node content.
*/
IN HRTREE destH,
IN int destRootId,
IN HRTREE srcH,
IN int srcRootId,
IN RTECompareTwo fcompare, /* compare two nodes */
IN void *param /* for compare function */
);
/* tree traveling */
int rtFirst (HRTREE rtH, int subTreeRoot);
int rtCurrent (HRTREE rtH);
/************************************************************************
* rtDoAll
* purpose: Execute a given function on all of the roots inside RTREE.
* Note that this function will only be called on the roots and
* not on all the allocated nodes.
* input : rtH - Handle to RTREE
* operation - Function to call on all roots
* param - Context parameter to use on calls
* output : none
* return : none
************************************************************************/
void rtDoAll(
IN HRTREE rtH,
IN RTEFunc operation,
IN void* param);
int rtFuncPrint (HRTREE rtH, int parent, void *param, int msa, RTEPFunc fprint);
int
rtPrint(
/* Recursive print of tree. */
IN HRTREE rtH,
IN int parent,
IN unsigned int layer, /* start printing layer */
IN int maxLevel, /* -1=infinite, 0==>parent node */
IN void * param,
IN void * msa);
int rtRoot (HRTREE rtH); /* returns location of first root in forest */
int rtCurSize (HRTREE rtH); /* returns current number of elements */
int rtMaxSize (HRTREE rtH); /* returns maximum number of elements */
int /* tree max usage */
rtMaxUsage(HRTREE rtH);
#endif
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -