diff --git a/libftasm/Makefile b/libftasm/Makefile index 63095c87..eb4ddbe0 100644 --- a/libftasm/Makefile +++ b/libftasm/Makefile @@ -207,6 +207,7 @@ htb/hashtab_remove.c\ htb/hashtab_destroy.c\ htb/hashtab_print.c\ htb/hashtab_generator.c\ +htb/hashtab_del.c\ SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE)) OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o)) diff --git a/libftasm/includes/hashtab.h b/libftasm/includes/hashtab.h index 7d64f21a..0cb7c7a7 100644 --- a/libftasm/includes/hashtab.h +++ b/libftasm/includes/hashtab.h @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/15 19:16:49 by ariard #+# #+# */ -/* Updated: 2017/06/21 18:39:01 by ariard ### ########.fr */ +/* Updated: 2017/06/22 20:25:20 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,10 @@ void hashtab_print(t_hashtab *htb, int (*printer)()); int ft_hash_string(const void *key, int size); -struct s_list *hashtab_generator(t_hashtab *htb, char init); +struct s_list *hashtab_iterator(t_hashtab *htb, char init); + +void hashtab_del(t_hashtab *htb, void *key, + int (*match)(const void *, const void *), + void (*del)(void *, size_t)); #endif diff --git a/libftasm/srcs/htb/hashtab_del.c b/libftasm/srcs/htb/hashtab_del.c new file mode 100644 index 00000000..33aa1480 --- /dev/null +++ b/libftasm/srcs/htb/hashtab_del.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* hashtab_del.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/06/22 17:04:24 by ariard #+# #+# */ +/* Updated: 2017/06/22 22:45:04 by ariard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "hashtab.h" + +void hashtab_del(t_hashtab *htb, void *key, + int (*match)(const void *, const void *), + void (*del)(void *, size_t)) +{ + int bucket; + + if ((bucket = htb->hashfunc(key, htb->capacity))) + ft_lst_delif(&htb->head[bucket], key, match, del); +} diff --git a/libftasm/srcs/htb/hashtab_generator.c b/libftasm/srcs/htb/hashtab_generator.c index 6fe7b055..d2f1ab73 100644 --- a/libftasm/srcs/htb/hashtab_generator.c +++ b/libftasm/srcs/htb/hashtab_generator.c @@ -6,13 +6,13 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/06/21 18:21:30 by ariard #+# #+# */ -/* Updated: 2017/06/21 19:54:30 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:43:01 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ #include "hashtab.h" -struct s_list *hashtab_generator(t_hashtab *htb, char init) +struct s_list *hashtab_iterator(t_hashtab *htb, char init) { static int bucket; static t_list *tmp; diff --git a/libftasm/srcs/htb/hashtab_init.c b/libftasm/srcs/htb/hashtab_init.c index 1f6b6db7..51673ad1 100644 --- a/libftasm/srcs/htb/hashtab_init.c +++ b/libftasm/srcs/htb/hashtab_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/15 19:13:06 by ariard #+# #+# */ -/* Updated: 2017/05/16 18:46:03 by ariard ### ########.fr */ +/* Updated: 2017/06/21 19:48:34 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/htb/hashtab_insert.c b/libftasm/srcs/htb/hashtab_insert.c index 45d6e1a4..9d2135c1 100644 --- a/libftasm/srcs/htb/hashtab_insert.c +++ b/libftasm/srcs/htb/hashtab_insert.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/15 19:30:39 by ariard #+# #+# */ -/* Updated: 2017/05/16 21:05:19 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:42:56 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/htb/hashtab_lookup.c b/libftasm/srcs/htb/hashtab_lookup.c index 99b6eb5f..97a1bd58 100644 --- a/libftasm/srcs/htb/hashtab_lookup.c +++ b/libftasm/srcs/htb/hashtab_lookup.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/15 19:38:41 by ariard #+# #+# */ -/* Updated: 2017/05/16 21:34:20 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:43:14 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ t_list *hashtab_lookup(t_hashtab *htb, void *key, { int bucket; - + if ((bucket = htb->hashfunc(key, htb->capacity))) return (ft_lst_find(htb->head[bucket], key, match)); return (NULL); diff --git a/libftasm/srcs/htb/hashtab_print.c b/libftasm/srcs/htb/hashtab_print.c index c6d5498b..5040f894 100644 --- a/libftasm/srcs/htb/hashtab_print.c +++ b/libftasm/srcs/htb/hashtab_print.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/16 20:38:14 by ariard #+# #+# */ -/* Updated: 2017/05/16 21:03:23 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:24:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,5 +18,5 @@ void hashtab_print(t_hashtab *htb, int (*printer)()) bucket = -1; while (++bucket != htb->capacity) - ft_lstiter(htb->head[bucket], printer, NULL); + ft_lstiter(htb->head[bucket], printer, &bucket); } diff --git a/libftasm/srcs/htb/hashtab_remove.c b/libftasm/srcs/htb/hashtab_remove.c index d21679b7..80c7a619 100644 --- a/libftasm/srcs/htb/hashtab_remove.c +++ b/libftasm/srcs/htb/hashtab_remove.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/15 19:46:48 by ariard #+# #+# */ -/* Updated: 2017/05/16 17:34:56 by ariard ### ########.fr */ +/* Updated: 2017/06/22 18:15:01 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lst_at.c b/libftasm/srcs/lst/ft_lst_at.c index 0013ce45..516c0147 100644 --- a/libftasm/srcs/lst/ft_lst_at.c +++ b/libftasm/srcs/lst/ft_lst_at.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/08/14 13:18:48 by jhalford #+# #+# */ -/* Updated: 2016/12/12 14:58:37 by jhalford ### ########.fr */ +/* Updated: 2017/06/21 18:33:52 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lst_delif.c b/libftasm/srcs/lst/ft_lst_delif.c index 7580ea7d..b14fcd85 100644 --- a/libftasm/srcs/lst/ft_lst_delif.c +++ b/libftasm/srcs/lst/ft_lst_delif.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:36:19 by jhalford ### ########.fr */ +/* Updated: 2017/06/22 17:16:50 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lst_find.c b/libftasm/srcs/lst/ft_lst_find.c index 420c8725..da738ceb 100644 --- a/libftasm/srcs/lst/ft_lst_find.c +++ b/libftasm/srcs/lst/ft_lst_find.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:20 by jhalford #+# #+# */ -/* Updated: 2017/05/16 21:27:55 by ariard ### ########.fr */ +/* Updated: 2017/06/21 18:20:30 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lst_removeif.c b/libftasm/srcs/lst/ft_lst_removeif.c index 5abf3726..e27041d2 100644 --- a/libftasm/srcs/lst/ft_lst_removeif.c +++ b/libftasm/srcs/lst/ft_lst_removeif.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */ -/* Updated: 2017/05/15 19:49:45 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:04:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lstdel.c b/libftasm/srcs/lst/ft_lstdel.c index ecebf830..f63c3f6b 100644 --- a/libftasm/srcs/lst/ft_lstdel.c +++ b/libftasm/srcs/lst/ft_lstdel.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */ -/* Updated: 2016/12/05 13:39:14 by jhalford ### ########.fr */ +/* Updated: 2017/06/22 16:57:53 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/lst/ft_lstdelone.c b/libftasm/srcs/lst/ft_lstdelone.c index d9743a95..7b950442 100644 --- a/libftasm/srcs/lst/ft_lstdelone.c +++ b/libftasm/srcs/lst/ft_lstdelone.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 13:39:33 by jhalford #+# #+# */ -/* Updated: 2017/03/18 17:17:50 by ariard ### ########.fr */ +/* Updated: 2017/06/22 22:36:02 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/srcs/mem/ft_memalloc.c b/libftasm/srcs/mem/ft_memalloc.c index 6a4a1112..c2908094 100644 --- a/libftasm/srcs/mem/ft_memalloc.c +++ b/libftasm/srcs/mem/ft_memalloc.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:25 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:43:51 by jhalford ### ########.fr */ +/* Updated: 2017/06/22 21:51:30 by ariard ### ########.fr */ /* */ /* ************************************************************************** */