eyBuildLib API Reference : eyBuildLib

ebtree

NAME

ebtree - tree operate lib

ROUTINES

treeInsChild( ) - insert pnew as last child node of pnode
treeAddChild( ) - insert pnew as last child node of pnode
treeDelete( ) - delete specify node and its sub tree nodes from root tree
treeParent( ) - get parent node of current node
treeChild( ) - get first child node of current node
treeChildNth( ) - get tree child by index(from 0)
treeSiblingNum( ) - get the number of sibling nodes, not include sub layer
treeChildNum( ) - get the number of child nodes, but not include sub layer
treeForEachChild( ) - done user hook for each child node, but not sub tree
forEachNode( ) - done user hook for each node in current subtree
treeFree( ) - free current tree and sub tree

DESCRIPTION

tree operate lib


eyBuildLib : Routines

treeInsChild( )

NAME

treeInsChild( ) - insert pnew as last child node of pnode

SYNOPSIS

int treeInsChild
    (
    TNODE * pnode,            /* where insert into */
    TNODE * pnew,             /* what insert into */
    int     index             /* index insert as */
    )

DESCRIPTION

this routine is to insert pnew as last child node of pnode

RETURN

OK/ERROR

SEE ALSO

ebtree


eyBuildLib : Routines

treeAddChild( )

NAME

treeAddChild( ) - insert pnew as last child node of pnode

SYNOPSIS

int treeAddChild
    (
    TNODE * pnode,
    TNODE * pnew
    )

DESCRIPTION

this routine is to insert pnew as last child node of pnode

RETURN

OK/ERROR

SEE ALSO

ebtree


eyBuildLib : Routines

treeDelete( )

NAME

treeDelete( ) - delete specify node and its sub tree nodes from root tree

SYNOPSIS

int treeDelete
    (
    TNODE * pnode,
     void (* free)(void * )
    )

DESCRIPTION

this routine is to delete specify node and its sub tree nodes from root tree, if pnode is the root of tree, this routine is same with treeFree( ).

RETURN

OK/ERROR

SEE ALSO

ebtree


eyBuildLib : Routines

treeParent( )

NAME

treeParent( ) - get parent node of current node

SYNOPSIS

TNODE * treeParent
    (
    TNODE * pnode
    )

DESCRIPTION

this routine is to get parent node of current node

RETURN

parent, or NULL

SEE ALSO

ebtree


eyBuildLib : Routines

treeChild( )

NAME

treeChild( ) - get first child node of current node

SYNOPSIS

TNODE * treeChild
    (
    TNODE * pnode
    )

DESCRIPTION

this routine is to get first child node of current node

RETURN

first child node, or NULL

SEE ALSO

ebtree


eyBuildLib : Routines

treeChildNth( )

NAME

treeChildNth( ) - get tree child by index(from 0)

SYNOPSIS

TNODE * treeChildNth
    (
    TNODE * pnode,
    int     num
    )

DESCRIPTION

this routine is to get first child node of current node

RETURN

first child node, or NULL

SEE ALSO

ebtree


eyBuildLib : Routines

treeSiblingNum( )

NAME

treeSiblingNum( ) - get the number of sibling nodes, not include sub layer

SYNOPSIS

int treeSiblingNum
    (
    TNODE * pnode
    )

DESCRIPTION

this routine is to get the number of sibling nodes, but not include sub layer

RETURN

number of sibling, or ERROR if pnode invalid

SEE ALSO

ebtree


eyBuildLib : Routines

treeChildNum( )

NAME

treeChildNum( ) - get the number of child nodes, but not include sub layer

SYNOPSIS

int treeChildNum
    (
    TNODE * pnode
    )

DESCRIPTION

this routine is to get the number of child of current node

RETURN

number of child, or ERROR if pnode invalid

SEE ALSO

ebtree


eyBuildLib : Routines

treeForEachChild( )

NAME

treeForEachChild( ) - done user hook for each child node, but not sub tree

SYNOPSIS

void treeForEachChild
    (
    TNODE *      pnode,       /* pointer to tree node descriptor */
    FUN_FOR_EACH done,        /* for each hook */
    void *       cookie,      /* hook parameter */
                 ...
    )

DESCRIPTION

this routine is to done user hook for each child node, but not sub tree. it means it only process directly child layer one by one.

NOTE

you can at most transfer 4 parameter to done hook.

RETURN

N/A

SEE ALSO

ebtree


eyBuildLib : Routines

forEachNode( )

NAME

forEachNode( ) - done user hook for each node in current subtree

SYNOPSIS

void treeForEach
    (
    TNODE *      pnode,       /* pointer to tree node descriptor */
    BOOL         order,       /* !0: preorder, 0 post order */
    FUN_FOR_EACH done,        /* for each hook */
    void *       cookie,      /* hook parameter */
                 ...
    )

DESCRIPTION

this routine is to done user hook for each node in current subtree. the preorder is to specify the traverse order. 0 means post-order, otherwise traverse with pre-order.

RETURN

N/A

SEE ALSO

ebtree


eyBuildLib : Routines

treeFree( )

NAME

treeFree( ) - free current tree and sub tree

SYNOPSIS

void treeFree
    (
    TNODE * proot,
     void (* free)(void * )
    )

DESCRIPTION

this routine is to done user hook for each node in current subtree

RETURN

N/A

SEE ALSO

ebtree