mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-25 17:00:17 +02:00
a463773c12
- jrb.c (recolor, jrb_delete_node, jrb_nblack, jrb_free_tree): add space to while(... - jrb.c (jrb_delete_node): flatten deletion of internal node - rbtest.c (main): add test of jrb_delete_node
42 lines
597 B
C
42 lines
597 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "jrb.h"
|
|
|
|
|
|
|
|
static int cmp(const void *a, const void *b)
|
|
{
|
|
return strcmp(a, b);
|
|
}
|
|
|
|
|
|
#define INSERT(key, val) \
|
|
jrb_insert(tree, key, val, cmp)
|
|
|
|
|
|
int main(void)
|
|
{
|
|
JRB tree = make_jrb();
|
|
JRB p;
|
|
|
|
INSERT("ab", "have");
|
|
INSERT("ac", "NOT");
|
|
INSERT("d", "little");
|
|
INSERT("c", "this");
|
|
INSERT("b", "passed");
|
|
INSERT("e", "regression");
|
|
INSERT("fa", "test");
|
|
INSERT("aa", "We");
|
|
INSERT("ff", "!");
|
|
|
|
p = jrb_find(tree, "ac", cmp);
|
|
jrb_delete_node(p);
|
|
|
|
jrb_traverse(p, tree)
|
|
printf("%s ", (char *) jrb_val(p));
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|