mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
hashmap: implement api to iterate a hashmap backwards
This commit is contained in:
parent
277e8c5ce4
commit
a1d84e3935
2 changed files with 42 additions and 1 deletions
|
|
@ -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,6 +60,9 @@ 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);
|
||||
|
||||
|
|
@ -69,4 +73,8 @@ void* pa_hashmap_first(pa_hashmap *h);
|
|||
#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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue