mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-02-18 22:05:37 -05:00
idxset: Add set contains() function
This is functionally equivalent to get_by_data(s, p, NULL) == p, but with a more obvious name and form because some existing code is instead manually iterating through idxsets to check for existence of an item. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/596>
This commit is contained in:
parent
def8eb074e
commit
fb63e58931
2 changed files with 17 additions and 0 deletions
|
|
@ -258,6 +258,20 @@ void* pa_idxset_get_by_data(pa_idxset*s, const void *p, uint32_t *idx) {
|
|||
return e->data;
|
||||
}
|
||||
|
||||
bool pa_idxset_contains(pa_idxset *s, const void *p) {
|
||||
unsigned hash;
|
||||
struct idxset_entry *e;
|
||||
|
||||
pa_assert(s);
|
||||
|
||||
hash = s->hash_func(p) % NBUCKETS;
|
||||
|
||||
if (!(e = data_scan(s, hash, p)))
|
||||
return false;
|
||||
|
||||
return e->data == p;
|
||||
}
|
||||
|
||||
void* pa_idxset_remove_by_index(pa_idxset*s, uint32_t idx) {
|
||||
struct idxset_entry *e;
|
||||
unsigned hash;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue