5 * strmap - an ordered map of strings to values
7 * This code implements an ordered map of strings 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 * License: CC0 (but some dependencies are LGPL!)
13 * Author: Rusty Russell <rusty@rustcorp.com.au>
15 * license_depends_compat FAIL
18 * #include <ccan/strmap/strmap.h>
21 * static bool dump(const char *member, size_t value, void *unused)
23 * printf("%s at %zu. ", member, value);
24 * // true means keep going with iteration.
28 * int main(int argc, char *argv[])
31 * struct { STRMAP_MEMBERS(size_t); } map;
34 * for (i = 1; i < argc; i++)
35 * // This only adds the first time for this arg.
36 * strmap_add(&map, argv[i], i);
38 * strmap_iterate(&map, dump, NULL);
42 * // Given 'foo' outputs 'foo at 1. '
43 * // Given 'foo bar' outputs 'bar at 2. foo at 1. '
44 * // Given 'foo foo bar zebra' outputs 'bar at 3. foo at 1. zebra at 4. '
46 int main(int argc, char *argv[])
48 /* Expect exactly one argument */
52 if (strcmp(argv[1], "depends") == 0) {
57 "ccan/typesafe_cb\n");