void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (!lst) return ; f(lst); return (ft_lstiter(lst->next, f)); }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (f) f(lst); if (lst->next) ft_lstiter(lst->next, f); }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (lst == NULL) return ; ft_lstiter(lst->next, f); (*f)(lst); }
int main(void) { char *line; t_list *tube; t_queen *ant; tube = NULL; ant = wake_queen_ant(); ft_putendl("Please enter map. Do not use '-' except for tubes."); while ((get_next_line(0, &line)) >= 0) { if (!ft_strcmp(line, "") || parse_lem(line, &ant, &tube) == -1) break ; else free(line); } if (ft_check_map_data(&ant, &tube)) explore_new_domain(&ant, &tube); else ft_putendl("ERROR"); ft_lstiter(tube, delete_tubes); ft_lstclear(&tube); destroy_queen(&ant); return (0); }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (lst) { f(lst); ft_lstiter((lst->next), f); } }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (lst && f) { (*f)(lst); ft_lstiter((*lst).next, f); } }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (lst && f) { ft_lstiter(lst->next, f); (*f)(lst); } }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { f(lst); if (lst->next != NULL) { ft_lstiter(lst->next, f); } }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { if (lst) { f(lst); if ((lst = lst->next)) ft_lstiter(lst, f); } }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { t_list *begin; begin = lst; f(begin); if (begin->next != NULL) ft_lstiter(begin->next, f); }
static void test1(t_test *test) { t_list *list; bzero((list = malloc(sizeof(t_list))), sizeof(t_list)); bzero(((list->next) = malloc(sizeof(t_list))), sizeof(t_list)); ft_lstiter(list, lstiter_test); mt_assert(list->content_size == 42); mt_assert(list->next->content_size == 42); }
void ft_jobs(char **argv, t_config *config) { size_t i; i = 1; ft_print_jobs(NULL, argv[i]); if (!config->jobs) { ft_error("jobs", NULL, "no current job", CR_ERROR); return ; } else if (!argv[i]) ft_lstiter(config->jobs, ft_print_list); else while (argv[i++]) { ft_lstiter(config->jobs, ft_print_list); ft_print_jobs(NULL, argv[i]); } }
void delete_current_test(t_list **test) { void (*func1)(t_list *); func1 = ft_lst_resetcontent; if (*test != NULL) { ft_lstiter(*test, ft_lst_resetcontent); ft_lstclear(test); } return ; }
int main(int ac, char **av) { if (ac != 3) return 1; else { t_list *mylist; t_list *new_link; mylist = ft_lstnew(av[1], ft_strlen(av[1])); new_link = ft_lstnew(av[2], ft_strlen(av[2])); ft_lstadd_end(&mylist, new_link); ft_lstiter(mylist, ft_print); } return 0; }
int ft_test_lstiter(void) { int res; int i1; int i2; t_list *elem; t_list *elem2; int *tmp1; int *tmp2; res = 0; i1 = 150; i2 = -130; ft_print_begin("ft_lstiter"); elem = (t_list*)malloc(sizeof(t_list)); elem2 = (t_list*)malloc(sizeof(t_list)); elem->next = elem2; elem->content = (void *)&i1; elem->content_size = elem2->content_size = sizeof(int); elem2->content = (void *)&i2; elem2->content_size = elem2->content_size = sizeof(int); elem2->next = NULL;; ft_lstiter(elem, ft_test_lstiter_iter); tmp1 = (int *) elem->content; tmp2 = (int *) elem2->content; if (*tmp1 != 151) { printf("*(elem->content) (%d) != (151)\n", *tmp1); res++; } else if (*tmp2 != -129) { printf("*(elem2->content) (%d) != (-129)\n", *tmp2); res++; } else { printf("Test passed function passed as argument was applied./n"); } printf("Test"); ft_print_status(res); return (ft_print_end(res)); }
static void destroy_queen(t_queen **ant) { if ((*ant)->rooms != NULL) { ft_lstiter((*ant)->rooms, delete_content_list); ft_lstclear(&(*ant)->rooms); } (*ant)->rooms = NULL; if ((*ant)->start != NULL) free((*ant)->start); if ((*ant)->end != NULL) free((*ant)->end); if ((*ant)->architect != NULL) free((*ant)->architect); (*ant)->start = NULL; (*ant)->end = NULL; free((*ant)); (*ant) = NULL; }
int uf_test_lstiter(void) { t_list *begin; size_t v; size_t w; v = 1; w = 2; begin = ft_lstnew(&v, sizeof(size_t)); begin->next = ft_lstnew(&w, sizeof(size_t)); ft_lstiter(begin, uf_iter_callback); if (*(size_t*)begin->content != 2) D_ERROR; if (*(size_t*)begin->next->content != 3) D_ERROR; free(begin->next); free(begin); return (1); }
void test_ft_lstiter(void) { t_list *lstiter_1; t_list *lstiter_2; t_list *lstiter_3; t_list *lstiter_4; t_list *lstiter_5; lstiter_1 = ft_lstnew(NULL, 147); lstiter_2 = ft_lstnew("This is test", 13); lstiter_3 = ft_lstnew("", 0); lstiter_4 = ft_lstnew("This_is_testing", 5); lstiter_5 = ft_lstnew("First element", 14); assert_true(lstiter_1->content == NULL); assert_true(lstiter_1->content_size == 0); assert_true(lstiter_1->next == NULL); assert_string_equal("This is test", lstiter_2->content); assert_true(lstiter_2->content_size == 13); assert_true(lstiter_2->next == NULL); assert_true(lstiter_3->content == NULL); assert_true(lstiter_3->content_size == 0); assert_true(lstiter_3->next == NULL); assert_string_equal("This_", lstiter_4->content); assert_true(lstiter_4->content_size == 5); assert_true(lstiter_4->next == NULL); assert_string_equal("First element", lstiter_5->content); assert_true(lstiter_5->content_size == 14); assert_true(lstiter_5->next == NULL); lstiter_1->next = lstiter_2; lstiter_2->next = lstiter_3; lstiter_3->next = lstiter_4; lstiter_4->next = lstiter_5; assert_true(lstiter_1->next == lstiter_2); assert_true(lstiter_2->next == lstiter_3); assert_true(lstiter_3->next == lstiter_4); assert_true(lstiter_4->next == lstiter_5); ft_lstiter(lstiter_1, test_ft_iter); assert_true(lstiter_1->content == NULL); assert_true(lstiter_1->content_size == 0); assert_true(lstiter_1->next == lstiter_2); assert_string_equal("Uijt!jt!uftu", lstiter_2->content); assert_true(lstiter_2->content_size == 13); assert_true(lstiter_2->next == lstiter_3); assert_true(lstiter_3->content == NULL); assert_true(lstiter_3->content_size == 0); assert_true(lstiter_3->next == lstiter_4); assert_string_equal("Uijt`", lstiter_4->content); assert_true(lstiter_4->content_size == 5); assert_true(lstiter_4->next == lstiter_5); assert_string_equal("Gjstu!fmfnfou", lstiter_5->content); assert_true(lstiter_5->content_size == 14); assert_true(lstiter_5->next == NULL); }
void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) { (*f)(lst); if (lst->next != NULL) ft_lstiter(lst->next, (*f)); }
void ft_lstiter(t_list *lst, t_list (*f)(t_list *elem)) { (*f)(lst); if (lst->next) ft_lstiter(lst->next, f); }