2020-05-09 19:34:25 +03:00
|
|
|
#ifndef __HASH_SET__
|
|
|
|
#define __HASH_SET__
|
|
|
|
|
|
|
|
#define DEFAULT_HASH_SET_CAPACITY 1 << 10
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
2020-05-09 19:34:25 +03:00
|
|
|
unsigned capacity;
|
|
|
|
unsigned length;
|
|
|
|
void **values;
|
|
|
|
void **keys;
|
|
|
|
} hash_set_t;
|
|
|
|
|
|
|
|
extern hash_set_t *init_hash_set();
|
|
|
|
|
|
|
|
extern unsigned add(hash_set_t *set, void *value);
|
|
|
|
|
|
|
|
unsigned put(hash_set_t *set, long long hash, void *value);
|
|
|
|
|
|
|
|
extern int contains(hash_set_t *set, void *value);
|
|
|
|
|
|
|
|
int contains_hash(hash_set_t *set, long long hash);
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
extern void delete (hash_set_t *set, void *value);
|
2020-05-09 19:34:25 +03:00
|
|
|
|
|
|
|
extern long long hash(void *value);
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
extern unsigned retrieve_index_from_hash(const long long hash,
|
|
|
|
const unsigned capacity);
|
2020-05-09 19:34:25 +03:00
|
|
|
|
|
|
|
extern void resize(hash_set_t *set);
|
|
|
|
|
|
|
|
#endif
|