X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fshash.h;h=471918b270242681475fcfc92318011c1cd3fd81;hb=67a4917b07031b387beafaedce413b4207214059;hp=9201bb5d92e0d3c01d65607af98ae33e50cd4c7d;hpb=a14bc59fb8f27db193d74662dc9c5cb8237177ef;p=openvswitch diff --git a/lib/shash.h b/lib/shash.h index 9201bb5d..471918b2 100644 --- a/lib/shash.h +++ b/lib/shash.h @@ -19,6 +19,10 @@ #include "hmap.h" +#ifdef __cplusplus +extern "C" { +#endif + struct shash_node { struct hmap_node node; char *name; @@ -31,12 +35,25 @@ struct shash { #define SHASH_INITIALIZER(SHASH) { HMAP_INITIALIZER(&(SHASH)->map) } +#define SHASH_FOR_EACH(SHASH_NODE, SHASH) \ + HMAP_FOR_EACH (SHASH_NODE, struct shash_node, node, &(SHASH)->map) + +#define SHASH_FOR_EACH_SAFE(SHASH_NODE, NEXT, SHASH) \ + HMAP_FOR_EACH_SAFE (SHASH_NODE, NEXT, struct shash_node, node, \ + &(SHASH)->map) + void shash_init(struct shash *); void shash_destroy(struct shash *); void shash_clear(struct shash *); -void shash_add(struct shash *, const char *, void *); +bool shash_is_empty(const struct shash *); +struct shash_node *shash_add(struct shash *, const char *, void *); void shash_delete(struct shash *, struct shash_node *); struct shash_node *shash_find(const struct shash *, const char *); void *shash_find_data(const struct shash *, const char *); +struct shash_node *shash_first(const struct shash *); + +#ifdef __cplusplus +} +#endif #endif /* shash.h */