#ifndef __SAFEC_SET_H
#define __SAFEC_SET_H
#include "types.h"
#include "hash.h"

typedef struct {
    hash_func_t hash_func;
    eq_func_t eq_func;
    double load_limit;

    size_t size;

    size_t __num_buckets;
    void** __buckets;
} set_t;

void set_init(
    set_t* set,
    hash_func_t hash_func,
    eq_func_t eq_func,
    double load_limit);
void set_init_capacity(
    set_t* set,
    hash_func_t hash_func,
    eq_func_t eq_func,
    double load_limit,
    size_t capacity);
void set_destroy(set_t* set);

bool set_contains(const set_t* set, const void* key);
void* set_get(const set_t* set, const void* key);
void* set_get_or_default(const set_t* set, const void* key, void* default_key);
void* set_add(set_t* set, void* key);
void set_put(set_t* set, void* key);
void* set_remove(set_t* set, const void* key);

typedef void (*set_foreach_func_t)(void* key, void* data);
void set_foreach(set_t* set, set_foreach_func_t foreach_func, void* data);

#endif
