util/set: add a set_clear function
Clear a set back to the state of having zero entries. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
affe63b1da
commit
5c075b0855
|
@ -155,6 +155,29 @@ _mesa_set_destroy(struct set *ht, void (*delete_function)(struct set_entry *entr
|
||||||
ralloc_free(ht);
|
ralloc_free(ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all values from the given set.
|
||||||
|
*
|
||||||
|
* If delete_function is passed, it gets called on each entry present before
|
||||||
|
* the set is cleared.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_set_clear(struct set *set, void (*delete_function)(struct set_entry *entry))
|
||||||
|
{
|
||||||
|
struct set_entry *entry;
|
||||||
|
|
||||||
|
if (!set)
|
||||||
|
return;
|
||||||
|
|
||||||
|
set_foreach (set, entry) {
|
||||||
|
if (delete_function)
|
||||||
|
delete_function(entry);
|
||||||
|
entry->key = deleted_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
set->entries = set->deleted_entries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a set entry with the given key and hash of that key.
|
* Finds a set entry with the given key and hash of that key.
|
||||||
*
|
*
|
||||||
|
|
|
@ -61,6 +61,9 @@ _mesa_set_create(void *mem_ctx,
|
||||||
void
|
void
|
||||||
_mesa_set_destroy(struct set *set,
|
_mesa_set_destroy(struct set *set,
|
||||||
void (*delete_function)(struct set_entry *entry));
|
void (*delete_function)(struct set_entry *entry));
|
||||||
|
void
|
||||||
|
_mesa_set_clear(struct set *set,
|
||||||
|
void (*delete_function)(struct set_entry *entry));
|
||||||
|
|
||||||
struct set_entry *
|
struct set_entry *
|
||||||
_mesa_set_add(struct set *set, const void *key);
|
_mesa_set_add(struct set *set, const void *key);
|
||||||
|
|
Loading…
Reference in New Issue