X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fobjset%2F_info;fp=ccan%2Fobjset%2F_info;h=cf290289b88387d18ffc8a8ced8ac474f96e4a57;hp=0000000000000000000000000000000000000000;hb=756749b2d337334b23deffcfe75b4f731f8f78d1;hpb=e6ed30e6896a8cc2df523c3a7e343252856142b4 diff --git a/ccan/objset/_info b/ccan/objset/_info new file mode 100644 index 00000000..cf290289 --- /dev/null +++ b/ccan/objset/_info @@ -0,0 +1,61 @@ +#include +#include "config.h" + +/** + * objset - unordered set of pointers. + * + * This code implements a very simple unordered set of pointers. It's very + * fast to add and check if something is in the set; it's implemented by + * a hash table. + * + * License: LGPL (v2.1 or any later version) + * + * Example: + * // Silly example to determine if an arg starts with a - + * #include + * #include + * + * struct objset_arg { + * OBJSET_MEMBERS(const char *); + * }; + * + * int main(int argc, char *argv[]) + * { + * struct objset_arg args; + * unsigned int i; + * + * objset_init(&args); + * // Put all args starting with - in the set. + * for (i = 1; i < argc; i++) + * if (argv[i][0] == '-') + * objset_add(&args, argv[i]); + * + * if (objset_empty(&args)) + * printf("No arguments start with -.\n"); + * else { + * for (i = 1; i < argc; i++) + * if (objset_get(&args, argv[i])) + * printf("%i,", i); + * printf("\n"); + * } + * return 0; + * } + * // Given 'a b c' outputs No arguments start with -. + * // Given 'a -b c' outputs 2, + * // Given 'a -b -c d' outputs 2,3, + */ +int main(int argc, char *argv[]) +{ + /* Expect exactly one argument */ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/hash\n"); + printf("ccan/htable\n"); + printf("ccan/tcon\n"); + return 0; + } + + return 1; +}