summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/hashmap.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-06-17 23:43:50 +0200
committerLennart Poettering <lennart@poettering.net>2009-06-17 23:43:50 +0200
commit53b87033aa04a504677d4c14b0b65caa58d16dbd (patch)
tree87bc32d0e83d8a9018fb10a7d308ae4a8ccf1f89 /src/pulsecore/hashmap.h
parent550b619558f03fb9e6d5d8072b9a4b15d9e6f91f (diff)
parent75256fb671b6ae8d784e0d6415d292fdbc6482c2 (diff)
Merge commit 'origin/master' into master-tx
Diffstat (limited to 'src/pulsecore/hashmap.h')
-rw-r--r--src/pulsecore/hashmap.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index 828e2448..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,14 +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