static void f_list_pick_cells_imp(t_list *const v_this, t_list_cell *const begin, t_list_cell *const end) { t_list_cell *cell_before; t_list_cell *cell_after; cell_before = D_LIST_CELL(prev)(begin); cell_after = D_LIST_CELL(next)(end); if (cell_before == NULL) { v_this->v_begin = cell_after; if (cell_after != NULL) cell_after->v_prev = NULL; } else cell_before->v_next = cell_after; if (cell_after == NULL) { if (D_LIST(begin)(v_this) != NULL) v_this->v_end = D_LIST_CELL(next)(v_this->v_begin); else v_this->v_end = D_LIST(begin)(v_this); } else cell_after->v_prev = cell_before; }
static void f_list_split_imp(t_list *v_this, t_list *new_list, t_list_cell *split_at) { new_list->v_begin = split_at; new_list->v_end = D_LIST(end)(v_this); new_list->v_size = D_LIST_CELL(count)(split_at, D_LIST(end)(v_this)); v_this->v_size = D_LIST(size)(v_this) - D_LIST(size)(new_list); v_this->v_end = D_LIST_CELL(prev)(split_at); v_this->v_end->v_next = NULL; new_list->v_begin->v_prev = NULL; new_list->v_end->v_next = NULL; }
t_list_cell *f_list_insert(t_list *v_this, t_list_cell *position, void *data) { t_list_cell *cell; if (position == NULL) { if (D_LIST(push_back)(v_this, data) == true) return (D_LIST(end)(v_this)); else return (NULL); } cell = D_LIST_CELL(create)(position->v_prev, position, data); if (cell != NULL) { if (D_LIST_CELL(prev)(position) != NULL) D_LIST_CELL(prev)(position)->v_next = cell; else v_this->v_begin = cell; position->v_prev = cell; v_this->v_size = D_LIST(size)(v_this) + 1; } return (cell); }
static size_t f_list_pick_cells(t_list *const v_this, t_list_cell *const begin, t_list_cell *end) { size_t cell_count; if (D_LIST(empty)(v_this) == true) return (0); if (end == NULL) end = D_LIST(end)(v_this); cell_count = D_LIST_CELL(count)(begin, end); D_LIST(pick_cells_imp)(v_this, begin, end); v_this->v_size = D_LIST(size)(v_this) - cell_count; begin->v_prev = NULL; end->v_next = NULL; return (cell_count); }
static void f_list_splice_imp(t_list *const v_this, t_list_cell *const position, t_list_cell *const other_begin, t_list_cell *const other_end) { t_list_cell *before; before = D_LIST_CELL(prev)(position); if (before == NULL) { v_this->v_begin = other_begin; v_this->v_begin->v_prev = NULL; } else { before->v_next = other_begin; other_begin->v_prev = before; } position->v_prev = other_end; other_end->v_next = position; }