diff --git a/libhashset/include/hash_map.h b/libhashset/include/hash_map.h index 9ed54a1..e520d57 100644 --- a/libhashset/include/hash_map.h +++ b/libhashset/include/hash_map.h @@ -9,7 +9,7 @@ #include #include -#if defined(_WIN32) && defined(HASHSET_DLL) +#if defined(_MSC_VER) && defined(HASHSET_DLL) # ifdef _HASHSET_EXPORTS # define HASHSET_API extern __declspec(dllexport) # else @@ -34,45 +34,59 @@ HASHSET_API const uint16_t HASHSET_VERSION_PATCH; HASHSET_API const char *const HASHSET_BUILD_DATE; HASHSET_API const char *const HASHSET_BUILD_TIME; +struct _hash_map16; struct _hash_map32; struct _hash_map64; +typedef struct _hash_map16 hash_map16_t; typedef struct _hash_map32 hash_map32_t; typedef struct _hash_map64 hash_map64_t; +HASHSET_API hash_map16_t *hash_map_create16(const size_t initial_capacity, const double load_factor); HASHSET_API hash_map32_t *hash_map_create32(const size_t initial_capacity, const double load_factor); HASHSET_API hash_map64_t *hash_map_create64(const size_t initial_capacity, const double load_factor); +HASHSET_API void hash_map_destroy16(hash_map16_t *const instance); HASHSET_API void hash_map_destroy32(hash_map32_t *const instance); HASHSET_API void hash_map_destroy64(hash_map64_t *const instance); +HASHSET_API errno_t hash_map_insert16(hash_map16_t *const instance, const uint16_t key, const uint16_t value); HASHSET_API errno_t hash_map_insert32(hash_map32_t *const instance, const uint32_t key, const uint32_t value); HASHSET_API errno_t hash_map_insert64(hash_map64_t *const instance, const uint64_t key, const uint64_t value); +HASHSET_API errno_t hash_map_remove16(hash_map16_t *const instance, const uint16_t key); HASHSET_API errno_t hash_map_remove32(hash_map32_t *const instance, const uint32_t key); HASHSET_API errno_t hash_map_remove64(hash_map64_t *const instance, const uint64_t key); +HASHSET_API errno_t hash_map_clear16(hash_map16_t *const instance); HASHSET_API errno_t hash_map_clear32(hash_map32_t *const instance); HASHSET_API errno_t hash_map_clear64(hash_map64_t *const instance); +HASHSET_API errno_t hash_map_contains16(const hash_map16_t *const instance, const uint16_t key); HASHSET_API errno_t hash_map_contains32(const hash_map32_t *const instance, const uint32_t key); HASHSET_API errno_t hash_map_contains64(const hash_map64_t *const instance, const uint64_t key); +HASHSET_API errno_t hash_map_get16(const hash_map16_t *const instance, const uint16_t key, uint16_t *const value); HASHSET_API errno_t hash_map_get32(const hash_map32_t *const instance, const uint32_t key, uint32_t *const value); HASHSET_API errno_t hash_map_get64(const hash_map64_t *const instance, const uint64_t key, uint64_t *const value); +HASHSET_API errno_t hash_map_iterate16(const hash_map16_t *const instance, size_t *const cursor, uint16_t *const key, uint16_t *const value); HASHSET_API errno_t hash_map_iterate32(const hash_map32_t *const instance, size_t *const cursor, uint32_t *const key, uint32_t *const value); HASHSET_API errno_t hash_map_iterate64(const hash_map64_t *const instance, size_t *const cursor, uint64_t *const key, uint64_t *const value); +HASHSET_API size_t hash_map_size16(const hash_map16_t* const instance); HASHSET_API size_t hash_map_size32(const hash_map32_t *const instance); HASHSET_API size_t hash_map_size64(const hash_map64_t *const instance); +HASHSET_API errno_t hash_map_info16(const hash_map16_t *const instance, size_t* const capacity, size_t* const valid, size_t* const deleted, size_t* const limit); HASHSET_API errno_t hash_map_info32(const hash_map32_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); HASHSET_API errno_t hash_map_info64(const hash_map64_t *const instance, size_t *const capacity, size_t *const valid, size_t *const deleted, size_t *const limit); +typedef int (*hash_map_callback16_t)(const size_t index, const char status, const uint32_t key, const uint16_t value); typedef int (*hash_map_callback32_t)(const size_t index, const char status, const uint32_t key, const uint32_t value); typedef int (*hash_map_callback64_t)(const size_t index, const char status, const uint64_t key, const uint64_t value); +HASHSET_API errno_t hash_map_dump16(const hash_map16_t *const instance, const hash_map_callback16_t callback); HASHSET_API errno_t hash_map_dump32(const hash_map32_t *const instance, const hash_map_callback32_t callback); HASHSET_API errno_t hash_map_dump64(const hash_map64_t *const instance, const hash_map_callback64_t callback); diff --git a/libhashset/include/hash_set.h b/libhashset/include/hash_set.h index bdb3331..6cc6648 100644 --- a/libhashset/include/hash_set.h +++ b/libhashset/include/hash_set.h @@ -9,7 +9,7 @@ #include #include -#if defined(_WIN32) && defined(HASHSET_DLL) +#if defined(_MSC_VER) && defined(HASHSET_DLL) # ifdef _HASHSET_EXPORTS # define HASHSET_API extern __declspec(dllexport) # else @@ -34,42 +34,55 @@ HASHSET_API const uint16_t HASHSET_VERSION_PATCH; HASHSET_API const char *const HASHSET_BUILD_DATE; HASHSET_API const char *const HASHSET_BUILD_TIME; +struct _hash_set16; struct _hash_set32; struct _hash_set64; +typedef struct _hash_set16 hash_set16_t; typedef struct _hash_set32 hash_set32_t; typedef struct _hash_set64 hash_set64_t; +HASHSET_API hash_set16_t *hash_set_create16(const size_t initial_capacity, const double load_factor); HASHSET_API hash_set32_t *hash_set_create32(const size_t initial_capacity, const double load_factor); HASHSET_API hash_set64_t *hash_set_create64(const size_t initial_capacity, const double load_factor); +HASHSET_API void hash_set_destroy16(hash_set16_t *const instance); HASHSET_API void hash_set_destroy32(hash_set32_t *const instance); HASHSET_API void hash_set_destroy64(hash_set64_t *const instance); +HASHSET_API errno_t hash_set_insert16(hash_set16_t *const instance, const uint16_t item); HASHSET_API errno_t hash_set_insert32(hash_set32_t *const instance, const uint32_t item); HASHSET_API errno_t hash_set_insert64(hash_set64_t *const instance, const uint64_t item); +HASHSET_API errno_t hash_set_remove16(hash_set16_t *const instance, const uint16_t item); HASHSET_API errno_t hash_set_remove32(hash_set32_t *const instance, const uint32_t item); HASHSET_API errno_t hash_set_remove64(hash_set64_t *const instance, const uint64_t item); +HASHSET_API errno_t hash_set_clear16(hash_set16_t *const instance); HASHSET_API errno_t hash_set_clear32(hash_set32_t *const instance); HASHSET_API errno_t hash_set_clear64(hash_set64_t *const instance); +HASHSET_API errno_t hash_set_contains16(const hash_set16_t *const instance, const uint16_t item); HASHSET_API errno_t hash_set_contains32(const hash_set32_t *const instance, const uint32_t item); HASHSET_API errno_t hash_set_contains64(const hash_set64_t *const instance, const uint64_t item); +HASHSET_API errno_t hash_set_iterate16(const hash_set16_t *const instance, size_t *const cursor, uint16_t *const item); HASHSET_API errno_t hash_set_iterate32(const hash_set32_t *const instance, size_t *const cursor, uint32_t *const item); HASHSET_API errno_t hash_set_iterate64(const hash_set64_t *const instance, size_t *const cursor, uint64_t *const item); +HASHSET_API size_t hash_set_size16(const hash_set16_t *const instance); HASHSET_API size_t hash_set_size32(const hash_set32_t *const instance); HASHSET_API size_t hash_set_size64(const hash_set64_t *const instance); +HASHSET_API errno_t hash_set_info16(const hash_set16_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_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); +typedef int (*hash_set_callback16_t)(const size_t index, const char status, const uint16_t item); typedef int (*hash_set_callback32_t)(const size_t index, const char status, const uint32_t item); typedef int (*hash_set_callback64_t)(const size_t index, const char status, const uint64_t item); +HASHSET_API errno_t hash_set_dump16(const hash_set16_t *const instance, const hash_set_callback16_t callback); HASHSET_API errno_t hash_set_dump32(const hash_set32_t *const instance, const hash_set_callback32_t callback); HASHSET_API errno_t hash_set_dump64(const hash_set64_t *const instance, const hash_set_callback64_t callback); diff --git a/libhashset/libhashset.vcxproj b/libhashset/libhashset.vcxproj index 19c256b..189fdfc 100644 --- a/libhashset/libhashset.vcxproj +++ b/libhashset/libhashset.vcxproj @@ -46,8 +46,10 @@ + + diff --git a/libhashset/libhashset.vcxproj.filters b/libhashset/libhashset.vcxproj.filters index 79a7fa2..1be189e 100644 --- a/libhashset/libhashset.vcxproj.filters +++ b/libhashset/libhashset.vcxproj.filters @@ -47,5 +47,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/libhashset/src/hash_map_16.c b/libhashset/src/hash_map_16.c new file mode 100644 index 0000000..adcc6f1 --- /dev/null +++ b/libhashset/src/hash_map_16.c @@ -0,0 +1,13 @@ +/******************************************************************************/ +/* HashSet for C99, by LoRd_MuldeR */ +/* This work has been released under the CC0 1.0 Universal license! */ +/******************************************************************************/ + +#include + +#define NAME_SUFFIX 16 +typedef hash_map16_t hash_map_t; +typedef hash_map_callback16_t hash_map_callback_t; +typedef uint16_t value_t; + +#include "generic_hash_map.h" diff --git a/libhashset/src/hash_set_16.c b/libhashset/src/hash_set_16.c new file mode 100644 index 0000000..89d96f9 --- /dev/null +++ b/libhashset/src/hash_set_16.c @@ -0,0 +1,13 @@ +/******************************************************************************/ +/* HashSet for C99, by LoRd_MuldeR */ +/* This work has been released under the CC0 1.0 Universal license! */ +/******************************************************************************/ + +#include + +#define NAME_SUFFIX 16 +typedef hash_set16_t hash_set_t; +typedef hash_set_callback16_t hash_set_callback_t; +typedef uint16_t value_t; + +#include "generic_hash_set.h"