|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
#include "libft.h"

Go to the source code of this file.
Functions | |
| size_t | hash_string (const char *key) |
| Default string hash function (djb2). | |
| bool | hashmap_need_resize (t_hashmap *map, const char *key) |
| bool | hashmap_resize (t_hashmap *map) |
| Doubles the bucket capacity and rehashes every stored pair. | |
| bool | hashmap_insert (t_hashmap *map, t_key_value *new) |
| Inserts a pair into the map, or replaces an existing one. | |
| size_t hash_string | ( | const char * | key | ) |
Default string hash function (djb2).
Computes a hash over the bytes of a NUL-terminated key. The returned value is reduced modulo the bucket count by the caller.
| key | NUL-terminated key to hash (borrowed). |

| bool hashmap_insert | ( | t_hashmap * | map, |
| t_key_value * | new | ||
| ) |
Inserts a pair into the map, or replaces an existing one.
Appends new to its target bucket chain. If a pair with the same key already exists in that bucket, its value is released through the map's del callback and the existing entry adopts new (see bucket_replace), in which case size is left unchanged.
| map | Pointer to an initialized map (borrowed). |
| new | Pair to insert (ownership transferred on success). |


| bool hashmap_need_resize | ( | t_hashmap * | map, |
| const char * | key | ||
| ) |


| bool hashmap_resize | ( | t_hashmap * | map | ) |
Doubles the bucket capacity and rehashes every stored pair.
Allocates a new bucket array of twice the current capacity, swaps it in and redistributes the existing pairs into it. The pairs themselves are moved, not reallocated. On failure the previous bucket array is restored, leaving the map unchanged.
| map | Pointer to an initialized map (borrowed). |

