with hashtab_del
This commit is contained in:
parent
0e35e0bd1e
commit
97ea87ec5c
16 changed files with 46 additions and 18 deletions
|
|
@ -207,6 +207,7 @@ htb/hashtab_remove.c\
|
||||||
htb/hashtab_destroy.c\
|
htb/hashtab_destroy.c\
|
||||||
htb/hashtab_print.c\
|
htb/hashtab_print.c\
|
||||||
htb/hashtab_generator.c\
|
htb/hashtab_generator.c\
|
||||||
|
htb/hashtab_del.c\
|
||||||
|
|
||||||
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
|
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
|
||||||
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
|
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/15 19:16:49 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);
|
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
|
#endif
|
||||||
|
|
|
||||||
23
libftasm/srcs/htb/hashtab_del.c
Normal file
23
libftasm/srcs/htb/hashtab_del.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* hashtab_del.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/06/21 18:21:30 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"
|
#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 int bucket;
|
||||||
static t_list *tmp;
|
static t_list *tmp;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/15 19:13:06 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/15 19:30:39 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/15 19:38:41 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/16 20:38:14 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;
|
bucket = -1;
|
||||||
while (++bucket != htb->capacity)
|
while (++bucket != htb->capacity)
|
||||||
ft_lstiter(htb->head[bucket], printer, NULL);
|
ft_lstiter(htb->head[bucket], printer, &bucket);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/05/15 19:46:48 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/08/14 13:18:48 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:12 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:20 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:30 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 15:18:57 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/05 13:39:33 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:25 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue