Started from buttom go to the sky

This commit is contained in:
Raphaël 2024-04-28 19:59:01 +02:00
parent 96215449bd
commit f811e55dea
4781 changed files with 10121 additions and 1743 deletions

View file

@ -0,0 +1,76 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hashmap_C__PREFIX__.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef HASHMAP_C__PREFIXUP___H
#define HASHMAP_C__PREFIXUP___H
#define DEFAULT_BUCKETS 750
C__TYPEHEADER__
#include "me/hash/hasher.h"
#include "me/types.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct s_kv_C__PREFIX__
{
C__KEYTYPE__ key;
C__VALTYPE__ val;
} t_kv_C__PREFIX__;
typedef void (*t_hash_C__PREFIX___fn)(t_hasher *hasher, C__KEYTYPE__ *key);
typedef void (*t_drop_C__PREFIX___fn)(t_kv_C__PREFIX__ val);
typedef bool (*t_eq_C__PREFIX___fn)(C__KEYTYPE__ *lhs, C__KEYTYPE__ *rhs);
typedef struct s_entry_C__PREFIX__
{
t_usize hash_id;
t_kv_C__PREFIX__ kv;
struct s_entry_C__PREFIX__ *next;
} t_entry_C__PREFIX__;
typedef struct s_hashmap_C__PREFIX__
{
t_entry_C__PREFIX__ **buckets;
t_usize num_buckets;
t_hasher hasher;
t_hash_C__PREFIX___fn hfunc;
t_eq_C__PREFIX___fn cfunc;
t_drop_C__PREFIX___fn drop;
} t_hashmap_C__PREFIX__;
t_hashmap_C__PREFIX__ *new_hashmap_C__PREFIX__(t_hash_C__PREFIX___fn hash,
t_eq_C__PREFIX___fn cmp,
t_drop_C__PREFIX___fn drop);
t_hashmap_C__PREFIX__ *new_hashmap_with_buckets_C__PREFIX__(
t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp,
t_drop_C__PREFIX___fn drop, size_t cap);
void drop_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap);
void insert_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ key,
C__VALTYPE__ value);
C__VALTYPE__ *get_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap,
C__KEYTYPE__ *key);
void remove_hashmap_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
t_entry_C__PREFIX__ *hashmap_get_entry_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap,
t_usize hash,
C__KEYTYPE__ *key,
t_entry_C__PREFIX__ **prev);
#endif

View file

@ -0,0 +1,57 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_C__PREFIX__.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */
/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VEC_C__PREFIXUP___H
#define VEC_C__PREFIXUP___H
C__TYPEHEADER__
#include "me/types.h"
typedef bool (*t_vec_C__PREFIX___sort_fn)(C__TYPENAME__ *, C__TYPENAME__ *);
typedef void (*t_free_C__PREFIX___item)(C__TYPENAME__);
typedef struct s_vec_C__PREFIX__
{
t_free_C__PREFIX___item free_func;
t_usize len;
t_usize capacity;
C__TYPENAME__ *buffer;
} t_vec_C__PREFIX__;
t_vec_C__PREFIX__ vec_C__PREFIX___new(t_usize capacity,
t_free_C__PREFIX___item free_function);
t_error vec_C__PREFIX___push(t_vec_C__PREFIX__ *vec, C__TYPENAME__ element);
t_error vec_C__PREFIX___push_front(t_vec_C__PREFIX__ *vec,
C__TYPENAME__ element);
t_error vec_C__PREFIX___pop(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value);
t_error vec_C__PREFIX___pop_front(t_vec_C__PREFIX__ *vec, C__TYPENAME__ *value);
void vec_C__PREFIX___free(t_vec_C__PREFIX__ vec);
t_error vec_C__PREFIX___reserve(t_vec_C__PREFIX__ *vec,
t_usize wanted_capacity);
t_error vec_C__PREFIX___find(t_vec_C__PREFIX__ *vec,
bool (*fn)(const C__TYPENAME__ *), t_usize *index);
t_error vec_C__PREFIX___find_starting(t_vec_C__PREFIX__ *vec,
bool (*fn)(const C__TYPENAME__ *),
t_usize starting_index, t_usize *index);
t_error vec_C__PREFIX___all(t_vec_C__PREFIX__ *vec,
bool (*fn)(const C__TYPENAME__ *), bool *result);
t_error vec_C__PREFIX___any(t_vec_C__PREFIX__ *vec,
bool (*fn)(const C__TYPENAME__ *), bool *result);
void vec_C__PREFIX___iter(t_vec_C__PREFIX__ *vec,
void (*fn)(t_usize index, C__TYPENAME__ *value,
void *state),
void *state);
void vec_C__PREFIX___reverse(t_vec_C__PREFIX__ *vec);
void vec_C__PREFIX___sort(t_vec_C__PREFIX__ *vec,
t_vec_C__PREFIX___sort_fn is_sorted);
#endif