mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
util/set: add helper _mesa_set_equal
This commit is contained in:
parent
f4812dc11d
commit
eb8dbc2bbf
2 changed files with 25 additions and 0 deletions
|
|
@ -700,3 +700,25 @@ _mesa_set_intersects(struct set *a, struct set *b)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
_mesa_set_equal(const struct set *a, const struct set *b)
|
||||
{
|
||||
assert(a->key_hash_function == b->key_hash_function);
|
||||
assert(a->key_equals_function == b->key_equals_function);
|
||||
|
||||
if (a->entries != b->entries)
|
||||
return false;
|
||||
|
||||
set_foreach(a, entry) {
|
||||
if (!_mesa_set_search_pre_hashed(b, entry->hash, entry->key))
|
||||
return false;
|
||||
}
|
||||
|
||||
set_foreach(b, entry) {
|
||||
if (!_mesa_set_search_pre_hashed(a, entry->hash, entry->key))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,9 @@ _mesa_pointer_set_create(void *mem_ctx);
|
|||
bool
|
||||
_mesa_set_intersects(struct set *a, struct set *b);
|
||||
|
||||
bool
|
||||
_mesa_set_equal(const struct set *a, const struct set *b);
|
||||
|
||||
/**
|
||||
* This foreach function is safe against deletion, but not against
|
||||
* insertion (which may rehash the set, making entry a dangling
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue