with generator on hashtab
This commit is contained in:
parent
4b35185e8f
commit
0e35e0bd1e
3 changed files with 37 additions and 1 deletions
|
|
@ -206,6 +206,7 @@ htb/hashtab_lookup.c\
|
|||
htb/hashtab_remove.c\
|
||||
htb/hashtab_destroy.c\
|
||||
htb/hashtab_print.c\
|
||||
htb/hashtab_generator.c\
|
||||
|
||||
SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE))
|
||||
OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/05/15 19:16:49 by ariard #+# #+# */
|
||||
/* Updated: 2017/05/16 21:03:50 by ariard ### ########.fr */
|
||||
/* Updated: 2017/06/21 18:39:01 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -43,4 +43,6 @@ 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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
33
libftasm/srcs/htb/hashtab_generator.c
Normal file
33
libftasm/srcs/htb/hashtab_generator.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* hashtab_generator.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/06/21 18:21:30 by ariard #+# #+# */
|
||||
/* Updated: 2017/06/21 19:54:30 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "hashtab.h"
|
||||
|
||||
struct s_list *hashtab_generator(t_hashtab *htb, char init)
|
||||
{
|
||||
static int bucket;
|
||||
static t_list *tmp;
|
||||
static t_list *prev;
|
||||
|
||||
if (init)
|
||||
{
|
||||
bucket = 0;
|
||||
tmp = htb->head[bucket];
|
||||
return (NULL);
|
||||
}
|
||||
while (!tmp && ++bucket < htb->capacity)
|
||||
tmp = htb->head[bucket];
|
||||
prev = tmp;
|
||||
if (tmp)
|
||||
tmp = tmp->next;
|
||||
return (prev);
|
||||
}
|
||||
Loading…
Reference in a new issue