2022-11-19 17:34:56 +01:00
|
|
|
/******************************************************************************/
|
|
|
|
/* HashSet for C99, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
|
|
|
/* This work has been released under the CC0 1.0 Universal license! */
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2022-11-29 21:22:23 +01:00
|
|
|
#ifndef _LIBHASHSET_SET_INCLUDED
|
|
|
|
#define _LIBHASHSET_SET_INCLUDED
|
2022-11-19 17:34:56 +01:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
#if defined(_MSC_VER) && defined(HASHSET_DLL)
|
2022-11-25 00:57:19 +01:00
|
|
|
# ifdef _HASHSET_EXPORTS
|
2022-11-25 00:45:35 +01:00
|
|
|
# define HASHSET_API extern __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define HASHSET_API extern __declspec(dllimport)
|
2022-11-25 00:57:19 +01:00
|
|
|
# endif
|
2022-11-25 00:45:35 +01:00
|
|
|
#else
|
|
|
|
# define HASHSET_API extern
|
|
|
|
#endif
|
|
|
|
|
2022-11-19 17:34:56 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-11-22 23:59:52 +01:00
|
|
|
#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_ERRNO_T_DEFINED)
|
|
|
|
typedef int errno_t;
|
|
|
|
#endif
|
|
|
|
|
2022-12-01 18:31:19 +01:00
|
|
|
/* ------------------------------------------------- */
|
|
|
|
/* Globals */
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
|
|
|
|
#ifndef _LIBHASHSET_GLOBALS_DEFINED
|
|
|
|
#define _LIBHASHSET_GLOBALS_DEFINED
|
|
|
|
|
2022-11-25 17:49:51 +01:00
|
|
|
HASHSET_API const uint16_t HASHSET_VERSION_MAJOR;
|
|
|
|
HASHSET_API const uint16_t HASHSET_VERSION_MINOR;
|
|
|
|
HASHSET_API const uint16_t HASHSET_VERSION_PATCH;
|
|
|
|
|
|
|
|
HASHSET_API const char *const HASHSET_BUILD_DATE;
|
|
|
|
HASHSET_API const char *const HASHSET_BUILD_TIME;
|
|
|
|
|
2022-12-01 18:31:19 +01:00
|
|
|
#endif /*_LIBHASHSET_GLOBALS_DEFINED*/
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
/* Types */
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
struct _hash_set16;
|
2022-11-27 19:46:01 +01:00
|
|
|
struct _hash_set32;
|
|
|
|
struct _hash_set64;
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
typedef struct _hash_set16 hash_set16_t;
|
2022-11-27 19:46:01 +01:00
|
|
|
typedef struct _hash_set32 hash_set32_t;
|
|
|
|
typedef struct _hash_set64 hash_set64_t;
|
|
|
|
|
2022-12-01 18:31:19 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
/* Functions */
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API hash_set16_t *hash_set_create16(const size_t initial_capacity, const double load_factor);
|
2022-11-27 19:46:01 +01:00
|
|
|
HASHSET_API hash_set32_t *hash_set_create32(const size_t initial_capacity, const double load_factor);
|
2022-11-27 21:01:46 +01:00
|
|
|
HASHSET_API hash_set64_t *hash_set_create64(const size_t initial_capacity, const double load_factor);
|
2022-11-27 19:46:01 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API void hash_set_destroy16(hash_set16_t *const instance);
|
2022-11-27 19:46:01 +01:00
|
|
|
HASHSET_API void hash_set_destroy32(hash_set32_t *const instance);
|
|
|
|
HASHSET_API void hash_set_destroy64(hash_set64_t *const instance);
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_insert16(hash_set16_t *const instance, const uint16_t item);
|
2022-11-29 21:22:23 +01:00
|
|
|
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);
|
2022-11-27 19:46:01 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_remove16(hash_set16_t *const instance, const uint16_t item);
|
2022-11-29 21:22:23 +01:00
|
|
|
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);
|
2022-11-27 19:46:01 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_clear16(hash_set16_t *const instance);
|
2022-11-27 19:46:01 +01:00
|
|
|
HASHSET_API errno_t hash_set_clear32(hash_set32_t *const instance);
|
|
|
|
HASHSET_API errno_t hash_set_clear64(hash_set64_t *const instance);
|
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_contains16(const hash_set16_t *const instance, const uint16_t item);
|
2022-11-29 21:22:23 +01:00
|
|
|
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);
|
2022-11-27 19:46:01 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_iterate16(const hash_set16_t *const instance, size_t *const cursor, uint16_t *const item);
|
2022-11-29 21:22:23 +01:00
|
|
|
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);
|
2022-11-19 17:34:56 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API size_t hash_set_size16(const hash_set16_t *const instance);
|
2022-11-27 19:46:01 +01:00
|
|
|
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);
|
2022-11-20 13:59:41 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
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);
|
2022-11-27 19:46:01 +01:00
|
|
|
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);
|
2022-11-19 17:34:56 +01:00
|
|
|
|
2022-12-01 16:06:12 +01:00
|
|
|
HASHSET_API errno_t hash_set_dump16(const hash_set16_t *const instance, const hash_set_callback16_t callback);
|
2022-11-30 14:40:43 +01:00
|
|
|
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);
|
2022-11-27 20:23:49 +01:00
|
|
|
|
2022-11-19 17:34:56 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-11-29 21:22:23 +01:00
|
|
|
#endif /*_LIBHASHSET_SET_INCLUDED*/
|