mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
Add wl_hash_table_for_each()
This commit is contained in:
parent
e908893080
commit
c4774d55e9
2 changed files with 18 additions and 0 deletions
|
|
@ -186,6 +186,20 @@ hash_table_search(struct wl_hash_table *ht, uint32_t hash)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_hash_table_for_each(struct wl_hash_table *ht,
|
||||||
|
wl_hash_table_func_t func, void *data)
|
||||||
|
{
|
||||||
|
struct hash_entry *entry;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < ht->size; i++) {
|
||||||
|
entry = ht->table + i;
|
||||||
|
if (entry_is_present(entry))
|
||||||
|
func(entry->data, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT void *
|
WL_EXPORT void *
|
||||||
wl_hash_table_lookup(struct wl_hash_table *ht, uint32_t hash)
|
wl_hash_table_lookup(struct wl_hash_table *ht, uint32_t hash)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,16 @@ struct wl_object {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*wl_hash_table_func_t)(void *element, void *data);
|
||||||
|
|
||||||
struct wl_hash_table;
|
struct wl_hash_table;
|
||||||
struct wl_hash_table *wl_hash_table_create(void);
|
struct wl_hash_table *wl_hash_table_create(void);
|
||||||
void wl_hash_table_destroy(struct wl_hash_table *ht);
|
void wl_hash_table_destroy(struct wl_hash_table *ht);
|
||||||
void *wl_hash_table_lookup(struct wl_hash_table *ht, uint32_t hash);
|
void *wl_hash_table_lookup(struct wl_hash_table *ht, uint32_t hash);
|
||||||
int wl_hash_table_insert(struct wl_hash_table *ht, uint32_t hash, void *data);
|
int wl_hash_table_insert(struct wl_hash_table *ht, uint32_t hash, void *data);
|
||||||
void wl_hash_table_remove(struct wl_hash_table *ht, uint32_t hash);
|
void wl_hash_table_remove(struct wl_hash_table *ht, uint32_t hash);
|
||||||
|
void wl_hash_table_for_each(struct wl_hash_table *ht,
|
||||||
|
wl_hash_table_func_t func, void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wl_list - linked list
|
* wl_list - linked list
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue