コード例 #1
0
ファイル: generic_list.c プロジェクト: 78boum/C---Epitech
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;
}
コード例 #2
0
ファイル: list3.c プロジェクト: Wayt/AnciensProjets
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;
}
コード例 #3
0
ファイル: stack.c プロジェクト: whitewidow13/C---Epitech
t_bool stack_pop(t_stack *stack_ptr) {
    return list_del_elem_at_front(stack_ptr);
}
コード例 #4
0
ファイル: queue.c プロジェクト: 78boum/C---Epitech
t_bool queue_pop(t_queue *queue_ptr) {
	return list_del_elem_at_front(queue_ptr);
}