Util: Enumerating a Table should list the key, too

This commit is contained in:
Jeffrey Pfau 2014-12-14 00:41:03 -08:00
parent 2b6462c3a8
commit 1b6389164c
2 changed files with 3 additions and 3 deletions

View File

@ -144,13 +144,13 @@ void TableClear(struct Table* table) {
}
}
void TableEnumerate(const struct Table* table, void (handler(void* value, void* user)), void* user) {
void TableEnumerate(const struct Table* table, void (handler(uint32_t 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(list->list[j].value, user);
handler(list->list[j].key, list->list[j].value, user);
}
}
}

View File

@ -25,7 +25,7 @@ void TableInsert(struct Table*, uint32_t key, void* value);
void TableRemove(struct Table*, uint32_t key);
void TableClear(struct Table*);
void TableEnumerate(const struct Table*, void (handler(void* value, void* user)), void* user);
void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user);
static inline void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) {
TableInit(table, initialSize, deinitializer);