5 * strset - an ordered set of strings
7 * This code implements an ordered set of string as a critbit tree. See:
9 * http://cr.yp.to/critbit.html
10 * http://github.com/agl/critbit (which this code is based on)
12 * Note that ccan/htable is faster and uses less memory, but doesn't provide
13 * ordered or prefix operations.
16 * // Print all words in order.
17 * #include <ccan/strset/strset.h>
18 * #include <ccan/grab_file/grab_file.h>
22 * static bool dump(const char *member, void *unused)
24 * printf("%s ", member);
25 * return true; // Keep going with iteration.
30 * struct strset words;
33 * strset_init(&words);
34 * file = grab_fd(NULL, 0, NULL);
36 * err(1, "Reading stdin");
38 * for (word = strtok(file, " \t\r\n");
40 * word = strtok(NULL, " \t\r\n")) {
41 * strset_add(&words, word);
43 * strset_iterate(&words, dump, NULL);
47 * // Given "foo bar" outputs "bar foo "
48 * // Given "foo foo bar" outputs "bar foo "
50 * License: CC0 (but some dependencies are LGPL!)
51 * Author: Rusty Russell <rusty@rustcorp.com.au>
53 * license_depends_compat FAIL
55 int main(int argc, char *argv[])
57 /* Expect exactly one argument */
61 if (strcmp(argv[1], "depends") == 0) {
66 "ccan/typesafe_cb\n");