2010-11-20 00:33:05 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "jrb.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-20 00:47:52 +02:00
|
|
|
static int cmp(const void *a, const void *b)
|
2010-11-20 00:33:05 +02:00
|
|
|
{
|
2010-11-20 00:47:52 +02:00
|
|
|
return strcmp(a, b);
|
2010-11-20 00:33:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define INSERT(key, val) \
|
2010-11-20 00:52:39 +02:00
|
|
|
jrb_insert(tree, key, val, cmp)
|
2010-11-20 00:33:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
JRB tree = make_jrb();
|
|
|
|
JRB p;
|
|
|
|
|
|
|
|
INSERT("ab", "have");
|
|
|
|
INSERT("d", "little");
|
|
|
|
INSERT("c", "this");
|
|
|
|
INSERT("b", "passed");
|
|
|
|
INSERT("e", "regression");
|
|
|
|
INSERT("fa", "test");
|
|
|
|
INSERT("aa", "We");
|
|
|
|
INSERT("ff", "!");
|
|
|
|
|
|
|
|
jrb_traverse(p, tree)
|
2010-11-20 00:47:52 +02:00
|
|
|
printf("%s ", (char *) jrb_val(p));
|
2010-11-20 00:33:05 +02:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|