6 * strmap - an ordered map of strings to values
8 * This code implements an ordered map of strings 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 * License: CC0 (but some dependencies are LGPL!)
14 * Author: Rusty Russell <rusty@rustcorp.com.au>
16 * license_depends_compat FAIL
19 * #include <ccan/strmap/strmap.h>
22 * static bool dump(const char *member, size_t value, void *unused)
24 * printf("%s at %zu. ", member, value);
25 * // true means keep going with iteration.
29 * int main(int argc, char *argv[])
32 * struct { STRMAP_MEMBERS(size_t); } map;
35 * for (i = 1; i < argc; i++)
36 * // This only adds the first time for this arg.
37 * strmap_add(&map, argv[i], i);
39 * strmap_iterate(&map, dump, NULL);
43 * // Given 'foo' outputs 'foo at 1. '
44 * // Given 'foo bar' outputs 'bar at 2. foo at 1. '
45 * // Given 'foo foo bar zebra' outputs 'bar at 3. foo at 1. zebra at 4. '
47 int main(int argc, char *argv[])
49 /* Expect exactly one argument */
53 if (strcmp(argv[1], "depends") == 0) {
58 "ccan/typesafe_cb\n");