mirror of https://github.com/mgba-emu/mgba.git
Util: Implement HashTableEnumerateCustom
This commit is contained in:
parent
a7710ed8d5
commit
fe10c00289
|
@ -70,7 +70,7 @@ void HashTableClear(struct Table*);
|
||||||
|
|
||||||
void HashTableEnumerate(const struct Table*, void (*handler)(const char* key, void* value, void* user), void* user);
|
void HashTableEnumerate(const struct Table*, void (*handler)(const char* key, void* value, void* user), void* user);
|
||||||
void HashTableEnumerateBinary(const struct Table*, void (*handler)(const char* key, size_t keylen, void* value, void* user), void* user);
|
void HashTableEnumerateBinary(const struct Table*, void (*handler)(const char* key, size_t keylen, void* value, void* user), void* user);
|
||||||
void HashTableEnumerateCustom(const struct Table*, void (*handler)(const char* key, void* value, void* user), void* user);
|
void HashTableEnumerateCustom(const struct Table*, void (*handler)(void* key, void* value, void* user), void* user);
|
||||||
const char* HashTableSearch(const struct Table* table, bool (*predicate)(const char* key, const void* value, const void* user), const void* user);
|
const char* HashTableSearch(const struct Table* table, bool (*predicate)(const char* key, const void* value, const void* user), const void* user);
|
||||||
const char* HashTableSearchPointer(const struct Table* table, const void* value);
|
const char* HashTableSearchPointer(const struct Table* table, const void* value);
|
||||||
const char* HashTableSearchData(const struct Table* table, const void* value, size_t bytes);
|
const char* HashTableSearchData(const struct Table* table, const void* value, size_t bytes);
|
||||||
|
|
|
@ -525,6 +525,17 @@ void HashTableEnumerateBinary(const struct Table* table, void (*handler)(const c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HashTableEnumerateCustom(const struct Table* table, void (*handler)(void* key, void* value, void* user), void* user) {
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < table->tableSize; ++i) {
|
||||||
|
const struct TableList* list = &table->table[i];
|
||||||
|
size_t j;
|
||||||
|
for (j = 0; j < list->nEntries; ++j) {
|
||||||
|
handler((char*) list->list[j].stringKey, list->list[j].value, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* HashTableSearch(const struct Table* table, bool (*predicate)(const char* key, const void* value, const void* user), const void* user) {
|
const char* HashTableSearch(const struct Table* table, bool (*predicate)(const char* key, const void* value, const void* user), const void* user) {
|
||||||
size_t i;
|
size_t i;
|
||||||
const char* result = NULL;
|
const char* result = NULL;
|
||||||
|
|
Loading…
Reference in New Issue