76 "Destination list must be empty before extracting a sublist";
79 LIST_NOT_EMPTY.
error (
"ELIST.assign_to_sublist",
ABORT,
nullptr);
81 last = start_it->extract_sublist (end_it);
110 const void *,
const void *)) {
129 qsort(base,
count,
sizeof(*base), comparator);
133 for (i = 0; i <
count; i++) {
151 int comparator(
const void*,
const void*),
154 if (last ==
nullptr || comparator(&last, &new_link) < 0) {
155 if (last ==
nullptr) {
156 new_link->next = new_link;
158 new_link->next = last->next;
159 last->next = new_link;
167 int compare = comparator(&link, &new_link);
170 }
else if (unique && compare == 0) {
205 started_cycling =
TRUE;
207 current = current->next;
209 if (ex_current_was_cycle_pt)
217 next = current->next;
222 "This is: %p Current is: %p",
this, current);
252 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
276 while (current != list->last)
294 const ERRCODE DONT_EXCHANGE_DELETED =
295 "Can't exchange deleted elements of lists";
304 if (!(other_it->list))
311 if ((list->
empty ()) ||
312 (other_it->list->
empty ()) || (current == other_it->current))
317 if (!current || !other_it->current)
318 DONT_EXCHANGE_DELETED.
error (
"ELIST_ITERATOR.exchange",
ABORT,
nullptr);
325 if ((next == other_it->current) ||
326 (other_it->next == current)) {
328 if ((next == other_it->current) &&
329 (other_it->next == current)) {
330 prev = next = current;
331 other_it->prev = other_it->next = other_it->current;
336 if (other_it->next == current) {
337 other_it->prev->next = current;
338 other_it->current->next = next;
339 current->next = other_it->current;
340 other_it->next = other_it->current;
344 prev->next = other_it->current;
345 current->next = other_it->next;
346 other_it->current->next = current;
348 other_it->prev = other_it->current;
353 prev->next = other_it->current;
354 current->next = other_it->next;
355 other_it->prev->next = current;
356 other_it->current->next = next;
362 if (list->last == current)
363 list->last = other_it->current;
364 if (other_it->list->last == other_it->current)
365 other_it->list->last = current;
367 if (current == cycle_pt)
368 cycle_pt = other_it->cycle_pt;
369 if (other_it->current == other_it->cycle_pt)
370 other_it->cycle_pt = cycle_pt;
374 old_current = current;
375 current = other_it->current;
376 other_it->current = old_current;
392 const ERRCODE BAD_EXTRACTION_PTS =
393 "Can't extract sublist from points on different lists";
394 const ERRCODE DONT_EXTRACT_DELETED =
395 "Can't extract a sublist marked by deleted points";
397 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
408 if (list != other_it->list)
409 BAD_EXTRACTION_PTS.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
413 if (!current || !other_it->current)
414 DONT_EXTRACT_DELETED.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
418 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
419 ex_current_was_cycle_pt =
FALSE;
420 other_it->ex_current_was_cycle_pt =
FALSE;
425 BAD_SUBLIST.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
429 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
432 if (temp_it.current == cycle_pt)
433 ex_current_was_cycle_pt =
TRUE;
435 if (temp_it.current == other_it->cycle_pt)
436 other_it->ex_current_was_cycle_pt =
TRUE;
440 while (temp_it.prev != other_it->current);
443 other_it->current->next = current;
444 end_of_new_list = other_it->current;
447 if (prev == other_it->current) {
448 list->last =
nullptr;
449 prev = current = next =
nullptr;
450 other_it->prev = other_it->current = other_it->next =
nullptr;
453 prev->next = other_it->next;
454 current = other_it->current =
nullptr;
455 next = other_it->next;
456 other_it->prev = prev;
458 return end_of_new_list;
void add_before_then_move(ELIST_LINK *new_link)
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)
ELIST_LINK * move_to_last()
void add_to_end(ELIST_LINK *new_link)
void sort(int comparator(const void *, const void *))
ELIST_LINK * add_sorted_and_find(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
const ERRCODE BAD_PARAMETER
ELIST_LINK * data_relative(int8_t offset)
void exchange(ELIST_ITERATOR *other_it)
void internal_clear(void(*zapper)(ELIST_LINK *))
void error(const char *caller, TessErrorLogCode action, const char *format,...) const