Loading...
Searching...
No Matches
dict.h
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
*/
#pragma once
#include <stdbool.h>
#include <stdio.h>
typedef void (*ec_dict_elt_free_t)(void *);
struct ec_dict;
struct ec_dict_elt_ref;
struct ec_dict *ec_dict(void);
void *ec_dict_get(const struct ec_dict *dict, const char *key);
bool ec_dict_has_key(const struct ec_dict *dict, const char *key);
int ec_dict_del(struct ec_dict *dict, const char *key);
int ec_dict_set(struct ec_dict *dict, const char *key, void *val, ec_dict_elt_free_t free_cb);
void ec_dict_free(struct ec_dict *dict);
size_t ec_dict_len(const struct ec_dict *dict);
struct ec_dict *ec_dict_dup(const struct ec_dict *dict);
void ec_dict_dump(FILE *out, const struct ec_dict *dict);
struct ec_dict_elt_ref *ec_dict_iter(const struct ec_dict *dict);
struct ec_dict_elt_ref *ec_dict_iter_next(struct ec_dict_elt_ref *iter);
const char *ec_dict_iter_get_key(const struct ec_dict_elt_ref *iter);
void *ec_dict_iter_get_val(const struct ec_dict_elt_ref *iter);
ec_dict_len
size_t ec_dict_len(const struct ec_dict *dict)
Get the length of a hash table.
ec_dict_has_key
bool ec_dict_has_key(const struct ec_dict *dict, const char *key)
Check if the hash table contains this key.
ec_dict_free
void ec_dict_free(struct ec_dict *dict)
Free a hash table and all its objects.
ec_dict
struct ec_dict * ec_dict(void)
Create a hash table.
ec_dict_iter_get_val
void * ec_dict_iter_get_val(const struct ec_dict_elt_ref *iter)
Get the value of the current element.
ec_dict_iter_next
struct ec_dict_elt_ref * ec_dict_iter_next(struct ec_dict_elt_ref *iter)
Make the iterator point to the next element in the hash table.
ec_dict_get
void * ec_dict_get(const struct ec_dict *dict, const char *key)
Get a value from the hash table.
ec_dict_dup
struct ec_dict * ec_dict_dup(const struct ec_dict *dict)
Duplicate a hash table.
ec_dict_elt_free_t
void(* ec_dict_elt_free_t)(void *)
Callback function for freeing dictionary elements.
Definition dict.h:21
ec_dict_iter_get_key
const char * ec_dict_iter_get_key(const struct ec_dict_elt_ref *iter)
Get a pointer to the key of the current element.
ec_dict_iter
struct ec_dict_elt_ref * ec_dict_iter(const struct ec_dict *dict)
Iterate the elements in the hash table.
ec_dict_del
int ec_dict_del(struct ec_dict *dict, const char *key)
Delete an object from the hash table.
ec_dict_dump
void ec_dict_dump(FILE *out, const struct ec_dict *dict)
Dump a hash table.
ec_dict_set
int ec_dict_set(struct ec_dict *dict, const char *key, void *val, ec_dict_elt_free_t free_cb)
Add/replace an object in the hash table.