hashmap: implement pa_hashmap_last()

This commit is contained in:
Lennart Poettering 2009-06-17 03:02:34 +02:00
parent a1d84e3935
commit c6830bd9dc
2 changed files with 12 additions and 0 deletions

View file

@ -279,6 +279,15 @@ void* pa_hashmap_first(pa_hashmap *h) {
return h->iterate_list_head->value;
}
void* pa_hashmap_last(pa_hashmap *h) {
pa_assert(h);
if (!h->iterate_list_tail)
return NULL;
return h->iterate_list_tail->value;
}
void* pa_hashmap_steal_first(pa_hashmap *h) {
void *data;

View file

@ -69,6 +69,9 @@ 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))