shash: New function shash_first().
authorBen Pfaff <blp@nicira.com>
Wed, 24 Jun 2009 17:21:39 +0000 (10:21 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 6 Jul 2009 16:07:23 +0000 (09:07 -0700)
lib/shash.c
lib/shash.h

index 7f69084..9316372 100644 (file)
@@ -97,3 +97,11 @@ shash_find_data(const struct shash *sh, const char *name)
     struct shash_node *node = shash_find(sh, name);
     return node ? node->data : NULL;
 }
+
+struct shash_node *
+shash_first(const struct shash *shash)
+{
+    struct hmap_node *node = hmap_first(&shash->map);
+    return node ? CONTAINER_OF(node, struct shash_node, node) : NULL;
+}
+
index 469e66e..bcac41b 100644 (file)
@@ -39,5 +39,6 @@ void 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 *);
 
 #endif /* shash.h */