Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
buckets.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* buckets.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: gastesan <gastesan@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/06/11 16:22:55 by adouieb #+# #+# */
9/* Updated: 2026/06/28 14:40:02 by gastesan ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef BUCKETS_H
14# define BUCKETS_H
15
16# include "libft.h"
17
28bool buckets_init(t_vector *buckets, size_t init_cap);
29
39void buckets_free(t_vector *buckets, void (*del)(void *));
40
51void buckets_detach(t_vector *buckets);
52
62void buckets_swap(t_vector *buckets1, t_vector *buckets2);
63
75void buckets_foreach(t_vector *vector, void (*del)(void *),
76 void (*f)(void *, void (*del)(void *)));
77
87void bucket_free(void *bucket_ptr, void (*del)(void *));
88
96bool bucket_contains(t_list bucket, const char *key);
97
107void bucket_detach(void *bucket, void (*_)(void *));
108
123void bucket_replace(t_list bucket, t_key_value *new, void (*del)(void *));
124#endif
void buckets_swap(t_vector *buckets1, t_vector *buckets2)
Swaps the contents of two bucket vectors.
Definition swap.c:15
void buckets_free(t_vector *buckets, void(*del)(void *))
Frees the bucket array and every pair it contains.
Definition init.c:37
void buckets_detach(t_vector *buckets)
Detaches every pair from the bucket chains without freeing them.
Definition detach.c:29
void bucket_free(void *bucket_ptr, void(*del)(void *))
Frees a single bucket chain and its pairs.
Definition init.c:16
void bucket_replace(t_list bucket, t_key_value *new, void(*del)(void *))
Replaces the value of the pair matching new->key within a chain.
Definition replace.c:16
void buckets_foreach(t_vector *vector, void(*del)(void *), void(*f)(void *, void(*del)(void *)))
Applies a function to every used bucket slot.
Definition utils.c:15
void bucket_detach(void *bucket, void(*_)(void *))
Detaches every pair from a single bucket chain without freeing them.
Definition detach.c:16
bool bucket_contains(t_list bucket, const char *key)
Tests whether a bucket chain holds a pair with the given key.
Definition contains.c:16
bool buckets_init(t_vector *buckets, size_t init_cap)
Initializes the bucket array.
Definition init.c:29
Key/value pair stored inside a hashmap bucket.
Definition libft.h:192
Doubly linked list node structure.
Definition libft.h:102
Dynamic array storing contiguous fixed-size items.
Definition libft.h:160