Archived
1
0
Fork 0

some cleanup and extended insertion in rbtree, updated rbtree test

This commit is contained in:
Henrik Hautakoski 2010-04-28 08:49:15 +02:00 committed by Henrik Hautakoski
parent 401b11fdcf
commit f630cbf979
8 changed files with 382 additions and 310 deletions

View file

@ -1,24 +1,7 @@
/*
* Copyright (C) 2010 Archived
*
* This program 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, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __COMMON_RBTREE_H
#ifndef _COMMON_RBTREE_H
#define _COMMON_RBTREE_H
#define __COMMON_RBTREE_H
#define RB_RED 0
#define RB_BLACK 1
@ -30,6 +13,7 @@ typedef unsigned int uint;
typedef struct _rbn {
uint key;
void *data;
size_t len;
struct _rbn *child[2];
color_t color;
} rbnode;
@ -38,13 +22,7 @@ typedef struct {
rbnode *root;
} rbtree;
#ifdef RB_DEBUG
int rb_assert(rbnode *node);
#endif
int rbtree_insert(rbtree *tree, uint key, void *data);
void* rbtree_delete(rbtree *tree, uint key);
int rbtree_is_empty(rbtree *tree);
rbnode* rbtree_search(rbtree *tree, uint key);
@ -54,6 +32,8 @@ void rbtree_walk(rbtree *tree, void (*action)(rbnode *));
void rbtree_free(rbtree *tree, void (*action)(rbnode *));
inline int rbtree_is_empty(rbtree *tree);
int rbtree_insert(rbtree *tree, uint key, void *data);
void* rbtree_delete(rbtree *tree, uint key);
#endif /* _COMMON_RBTREE_H */