t_bool list_del_elem_at_position(t_list* front_ptr, unsigned int position) { if (position == 0) { return list_del_elem_at_front(front_ptr); } if (!*front_ptr) { return FALSE; } t_list previous = *front_ptr; t_list list = previous->next; while (--position) { if (!list) { return FALSE; previous = list; list = list->next;} } if (list) { previous->next = list->next; } free(list); return TRUE; }
t_bool list_del_elem_at_position(t_list* front_ptr, unsigned int position) { unsigned int i; t_list elem; if (position == 0) return list_del_elem_at_front(front_ptr); if (*front_ptr == NULL) return LFALSE; elem = *front_ptr; i = 1; while (i != position && elem->next) { ++i; elem = elem->next; } if (i != position || elem->next == NULL) return LFALSE; elem->next = elem->next->next; return LTRUE; }
t_bool stack_pop(t_stack *stack_ptr) { return list_del_elem_at_front(stack_ptr); }
t_bool queue_pop(t_queue *queue_ptr) { return list_del_elem_at_front(queue_ptr); }