6 * strset - an ordered set of strings
8 * This code implements an ordered set of string as a critbit tree. See:
10 * http://cr.yp.to/critbit.html
11 * http://github.com/agl/critbit (which this code is based on)
13 * Note that ccan/htable is faster and uses less memory, but doesn't provide
14 * ordered or prefix operations.
17 * // Print all words in order.
18 * #include <ccan/strset/strset.h>
19 * #include <ccan/tal/grab_file/grab_file.h>
23 * static bool dump(const char *member, void *unused)
25 * printf("%s ", member);
26 * return true; // Keep going with iteration.
31 * struct strset words;
34 * strset_init(&words);
35 * file = grab_fd(NULL, 0);
37 * err(1, "Reading stdin");
39 * for (word = strtok(file, " \t\r\n");
41 * word = strtok(NULL, " \t\r\n")) {
42 * strset_add(&words, word);
44 * strset_iterate(&words, dump, NULL);
48 * // Given "foo bar" outputs "bar foo \n"
49 * // Given "foo foo bar" outputs "bar foo \n"
51 * License: CC0 (but some dependencies are LGPL!)
52 * Author: Rusty Russell <rusty@rustcorp.com.au>
54 * license_depends_compat FAIL
56 int main(int argc, char *argv[])
58 /* Expect exactly one argument */
62 if (strcmp(argv[1], "depends") == 0) {
67 "ccan/typesafe_cb\n");