Beispiel #1
0
void util_rbtree_mid_travel(util_rbtree_t *rbtree,
                            void(*opera)(util_rbtree_node_t *, void *), void *data)
{
    if((rbtree!=NULL) && !util_rbtree_isempty(rbtree))
    {
        rbtree_mid_travel(rbtree->root, _NULL(rbtree), opera, data);
    }
}
Beispiel #2
0
void conhash_fini(struct conhash_s *conhash)
{
	if(conhash != NULL)
	{
		/* free rb tree */
        while(!util_rbtree_isempty(&(conhash->vnode_tree)))
        {
            util_rbtree_node_t *rbnode = conhash->vnode_tree.root;
            util_rbtree_delete(&(conhash->vnode_tree), rbnode);
            __conhash_del_rbnode(rbnode);
        }
		free(conhash);
	}
}
Beispiel #3
0
util_rbtree_node_t* util_rbtree_lookup(util_rbtree_t *rbtree, long key)
{
	if((rbtree != NULL) && !util_rbtree_isempty(rbtree))
	{
		util_rbtree_node_t *node = NULL;
        util_rbtree_node_t *temp = rbtree->root;
		util_rbtree_node_t *null = _NULL(rbtree);
		while(temp != null)
		{
			if(key <= temp->key)
            {
                node = temp; /* update node */
                temp = temp->left;
            }
			else if(key > temp->key)
            {
                temp = temp->right;
            }
		}
        /* if node==NULL return the minimum node */
        return ((node != NULL) ? node : util_rbtree_min(rbtree));
	}
    return NULL;
}