diff --git a/README.md b/README.md index 5de652f..e529892 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ API Reference This section describes the LibHashSet programming interface, as declared in the `` header file. -LibHashSet supports sets containing values of type `uint32_t` or `uint64_t`. For each value type, separate functions are provided. The functions for `uint32_t`- and `uint64_t`-based hash sets can be distinguished by the suffix `…32` and `…64` suffix, respectively. In the following, the functions are described in their "generic" form. +LibHashSet supports sets containing values of type `uint32_t` or `uint64_t`. For each value type, separate functions are provided. The functions for `uint32_t`- and `uint64_t`-based hash sets can be distinguished by the suffix `…32` and `…64`, respectively. In the following, the functions are described in their "generic" (`value_t`) form. ***Note:*** On Microsoft Windows, when using LibHashSet as a "shared" library (DLL), the macro `HASHSET_DLL` must be defined *before* including ``! This is **not** required or allowed when using the "static" library. @@ -401,7 +401,7 @@ Dump the current status and content of all "slots" of the hash set. ```C errno_t hash_set_dump( const hash_set_t *const instance, - int (*callback)(const size_t index, const int status, const uint32_t value) + int (*callback)(const size_t index, const char status, const value_t value) ); ``` @@ -416,8 +416,8 @@ errno_t hash_set_dump( ```C int callback( const size_t index, - const int status, - const uint32_t value + const char status, + const value_t value ); ``` ##### Parameters @@ -427,16 +427,16 @@ errno_t hash_set_dump( * `status` Indicates the status of the current "slot": - - `0` – slot is *unused* - - `1` – slot is *valid* - - `2` – slot is *deleted* + - `'u'` – the slot is *unused* + - `'v'` – the slot is *valid* + - `'d'` – the slot is *deleted* * `value` The value that is stored at the current "slot" index. ##### Return value - If the function returns *zero*, the iteration is cancelled; otherwise the iteration continues. + If the function returns a *non-zero* value, the iteration continues; otherwise it is cancelled. #### Return value diff --git a/libhashset/include/hash_set.h b/libhashset/include/hash_set.h index 2750ad4..9b46672 100644 --- a/libhashset/include/hash_set.h +++ b/libhashset/include/hash_set.h @@ -67,8 +67,8 @@ HASHSET_API size_t hash_set_size64(const hash_set64_t *const instance); HASHSET_API errno_t hash_set_info32(const hash_set32_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); HASHSET_API errno_t hash_set_info64(const hash_set64_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); -HASHSET_API errno_t hash_set_dump32(const hash_set32_t *const instance, int (*const callback)(const size_t index, const int status, const uint32_t value)); -HASHSET_API errno_t hash_set_dump64(const hash_set64_t *const instance, int (*const callback)(const size_t index, const int status, const uint64_t value)); +HASHSET_API errno_t hash_set_dump32(const hash_set32_t *const instance, int (*const callback)(const size_t index, const char status, const uint32_t value)); +HASHSET_API errno_t hash_set_dump64(const hash_set64_t *const instance, int (*const callback)(const size_t index, const char status, const uint64_t value)); #ifdef __cplusplus } diff --git a/libhashset/src/generic.h b/libhashset/src/generic.h index 4173e10..9dfdbb8 100644 --- a/libhashset/src/generic.h +++ b/libhashset/src/generic.h @@ -420,7 +420,7 @@ errno_t MAKE_NAME(hash_set_info)(const hash_set_t *const instance, size_t *const return 0; } -HASHSET_API errno_t MAKE_NAME(hash_set_dump)(const hash_set_t *const instance, int (*const callback)(const size_t index, const int status, const value_t value)) +HASHSET_API errno_t MAKE_NAME(hash_set_dump)(const hash_set_t *const instance, int (*const callback)(const size_t index, const char status, const value_t value)) { size_t index; @@ -431,7 +431,7 @@ HASHSET_API errno_t MAKE_NAME(hash_set_dump)(const hash_set_t *const instance, i for (index = 0U; index < instance->data.capacity; ++index) { - if (!callback(index, get_flag(instance->data.used, index) ? (get_flag(instance->data.deleted, index) ? 2 : 1) : 0, instance->data.values[index])) + if (!callback(index, get_flag(instance->data.used, index) ? (get_flag(instance->data.deleted, index) ? 'd' : 'v') : 'u', instance->data.values[index])) { return ECANCELED; }