Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
archived/src/rbtree.h
2010-11-03 08:35:58 +01:00

49 lines
1.1 KiB
C

/* rbtree.h
*
* Copyright (C) 2010 Henrik Hautakoski <henrik@fiktivkod.org>
*
* 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.
*/
#ifndef __RBTREE_H
#define __RBTREE_H
#define RB_RED 0
#define RB_BLACK 1
#include <stddef.h>
typedef unsigned char color_t;
typedef unsigned int uint;
/* node definition */
typedef struct _rbn {
uint key;
void *data;
size_t len;
struct _rbn *child[2];
color_t color;
} rbnode;
typedef struct {
rbnode *root;
} rbtree;
int rbtree_is_empty(rbtree *tree);
rbnode* rbtree_search(rbtree *tree, uint key);
rbnode* rbtree_cmp_search(rbtree *tree, void *cmpdata, size_t len);
void rbtree_walk(rbtree *tree, void (*action)(rbnode *));
void rbtree_free(rbtree *tree, void (*action)(rbnode *));
int rbtree_insert(rbtree *tree, uint key, void *data, size_t len);
void* rbtree_delete(rbtree *tree, uint key);
#endif /* __RBTREE_H */