Archived
1
0
Fork 0

rbtree.c: make rbnode an ADT.

This commit is contained in:
Henrik Hautakoski 2011-01-08 08:10:23 +01:00
parent 41a253a00a
commit e7ebbd30ec
3 changed files with 15 additions and 39 deletions

View file

@ -19,6 +19,16 @@
#include "xalloc.h"
#include "rbtree.h"
#define RB_RED 0
#define RB_BLACK 1
/* node definition */
typedef struct _rbn {
const void *key;
struct _rbn *child[2];
unsigned char color;
} rbnode;
#define is_red(n) ((n) != NULL && (n)->color == RB_RED)
#define swap(n,d,q) ((n)->child[(n)->child[d] == (q)])

View file

@ -11,20 +11,10 @@
#ifndef __RBTREE_H
#define __RBTREE_H
#define RB_RED 0
#define RB_BLACK 1
#include <stddef.h>
/* node definition */
typedef struct _rbn {
const void *key;
struct _rbn *child[2];
unsigned char color;
} rbnode;
typedef struct {
rbnode *root;
struct _rbn *root;
/* user defined operations */
void (*delete_fn)(void *);
void (*update_fn)(void *, void *);