summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/hashmap.h
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2009-06-29 18:35:06 +0300
committerTanu Kaskinen <tanuk@iki.fi>2009-06-29 18:35:06 +0300
commit0bc538b08ca5c4efea86700cb6c4685da3f34345 (patch)
treee5b0fe4b967ecb7e9251faf21904bbbe825aaab7 /src/pulsecore/hashmap.h
parentb152f3a052eca7225870a7dc4d8a719bee107f0f (diff)
parent2654eb7781ddcfe53064745bbad77bffe5c8eada (diff)
Merge branch 'master' into dbus-work
Conflicts: src/daemon/daemon-conf.c src/daemon/daemon-conf.h src/daemon/main.c src/pulsecore/dbus-util.h
Diffstat (limited to 'src/pulsecore/hashmap.h')
-rw-r--r--src/pulsecore/hashmap.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index 08e18ead..ac2092a6 100644
--- a/src/pulsecore/hashmap.h
+++ b/src/pulsecore/hashmap.h
@@ -26,7 +26,8 @@
/* Simple Implementation of a hash table. Memory management is the
* user's job. It's a good idea to have the key pointer point to a
- * string in the value data. */
+ * string in the value data. The insertion order is preserved when
+ * iterating. */
typedef struct pa_hashmap pa_hashmap;
@@ -59,10 +60,24 @@ pa_bool_t pa_hashmap_isempty(pa_hashmap *h);
returned. */
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void**key);
+/* Same as pa_hashmap_iterate() but goes backwards */
+void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void**key);
+
/* Remove the oldest entry in the hashmap and return it */
void *pa_hashmap_steal_first(pa_hashmap *h);
/* Return the oldest entry in the hashmap */
void* pa_hashmap_first(pa_hashmap *h);
+/* Return the newest entry in the hashmap */
+void* pa_hashmap_last(pa_hashmap *h);
+
+/* A macro to ease iteration through all entries */
+#define PA_HASHMAP_FOREACH(e, h, state) \
+ for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), NULL); (e); (e) = pa_hashmap_iterate((h), &(state), NULL))
+
+/* A macro to ease iteration through all entries, backwards */
+#define PA_HASHMAP_FOREACH_BACKWARDS(e, h, state) \
+ for ((state) = NULL, (e) = pa_hashmap_iterate_backwards((h), &(state), NULL); (e); (e) = pa_hashmap_iterate_backwards((h), &(state), NULL))
+
#endif