Root/qpkg/rbtest.c

Source at commit a9f12d56661a8e6def5a2b32519c3efd55e38d31 created 8 years 11 months ago.
By Werner Almesberger, qpkg: converted ID comparison from "struct id *" to "void *"
1#include <stdio.h>
2#include <string.h>
3
4#include "jrb.h"
5
6
7
8static int cmp(const void *a, const void *b)
9{
10    return strcmp(a, b);
11}
12
13
14#define INSERT(key, val) \
15    jrb_insert(tree, key, val, cmp)
16
17
18int main(void)
19{
20    struct jrb *tree = make_jrb();
21    struct jrb *p;
22
23    INSERT("ab", "have");
24    INSERT("ac", "NOT");
25    INSERT("d", "little");
26    INSERT("c", "this");
27    INSERT("b", "passed");
28    INSERT("e", "regression");
29    INSERT("fa", "test");
30    INSERT("aa", "We");
31    INSERT("ff", "!");
32
33    p = jrb_find(tree, "ac", cmp);
34    jrb_delete_node(p);
35
36    jrb_traverse(p, tree)
37        printf("%s ", (char *) jrb_val(p));
38    printf("\n");
39
40    return 0;
41}
42

Archive Download this file

Branches:
master



interactive