77 "Destination list must be empty before extracting a sublist";
80 LIST_NOT_EMPTY.
error (
"ELIST2.assign_to_sublist",
ABORT,
nullptr);
82 last = start_it->extract_sublist (end_it);
111 const void *,
const void *)) {
130 qsort(base,
count,
sizeof(*base), comparator);
134 for (i = 0; i <
count; i++) {
149 if (last ==
nullptr || comparator(&last, &new_link) < 0) {
150 if (last ==
nullptr) {
151 new_link->next = new_link;
152 new_link->prev = new_link;
154 new_link->next = last->next;
155 new_link->prev = last;
156 last->next = new_link;
157 new_link->next->prev = new_link;
165 if (comparator(&link, &new_link) > 0)
198 started_cycling =
TRUE;
200 current = current->next;
203 if (ex_current_was_cycle_pt)
213 next = current->next;
218 "This is: %p Current is: %p",
this, current);
242 started_cycling =
TRUE;
244 current = current->prev;
246 if (ex_current_was_cycle_pt)
256 "This is: %p Current is: %p",
this, current);
259 prev = current->prev;
282 for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);
284 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
306 const ERRCODE DONT_EXCHANGE_DELETED =
307 "Can't exchange deleted elements of lists";
316 if (!(other_it->list))
323 if ((list->
empty ()) ||
324 (other_it->list->
empty ()) || (current == other_it->current))
329 if (!current || !other_it->current)
330 DONT_EXCHANGE_DELETED.
error (
"ELIST2_ITERATOR.exchange",
ABORT,
nullptr);
337 if ((next == other_it->current) ||
338 (other_it->next == current)) {
340 if ((next == other_it->current) &&
341 (other_it->next == current)) {
342 prev = next = current;
343 other_it->prev = other_it->next = other_it->current;
348 if (other_it->next == current) {
349 other_it->prev->next = current;
350 other_it->current->next = next;
351 other_it->current->prev = current;
352 current->next = other_it->current;
353 current->prev = other_it->prev;
354 next->prev = other_it->current;
356 other_it->next = other_it->current;
360 prev->next = other_it->current;
361 current->next = other_it->next;
362 current->prev = other_it->current;
363 other_it->current->next = current;
364 other_it->current->prev = prev;
365 other_it->next->prev = current;
368 other_it->prev = other_it->current;
373 prev->next = other_it->current;
374 current->next = other_it->next;
375 current->prev = other_it->prev;
376 next->prev = other_it->current;
377 other_it->prev->next = current;
378 other_it->current->next = next;
379 other_it->current->prev = prev;
380 other_it->next->prev = current;
386 if (list->last == current)
387 list->last = other_it->current;
388 if (other_it->list->last == other_it->current)
389 other_it->list->last = current;
391 if (current == cycle_pt)
392 cycle_pt = other_it->cycle_pt;
393 if (other_it->current == other_it->cycle_pt)
394 other_it->cycle_pt = cycle_pt;
398 old_current = current;
399 current = other_it->current;
400 other_it->current = old_current;
416 const ERRCODE BAD_EXTRACTION_PTS =
417 "Can't extract sublist from points on different lists";
418 const ERRCODE DONT_EXTRACT_DELETED =
419 "Can't extract a sublist marked by deleted points";
421 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
432 if (list != other_it->list)
433 BAD_EXTRACTION_PTS.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
nullptr);
437 if (!current || !other_it->current)
438 DONT_EXTRACT_DELETED.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
442 ex_current_was_last = other_it->ex_current_was_last =
false;
443 ex_current_was_cycle_pt =
false;
444 other_it->ex_current_was_cycle_pt =
false;
449 BAD_SUBLIST.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
nullptr);
453 ex_current_was_last = other_it->ex_current_was_last =
true;
456 if (temp_it.current == cycle_pt)
457 ex_current_was_cycle_pt =
true;
459 if (temp_it.current == other_it->cycle_pt)
460 other_it->ex_current_was_cycle_pt =
true;
465 while (temp_it.prev != other_it->current);
468 other_it->current->next = current;
470 current->prev = other_it->current;
471 end_of_new_list = other_it->current;
474 if (prev == other_it->current) {
475 list->last =
nullptr;
476 prev = current = next =
nullptr;
477 other_it->prev = other_it->current = other_it->next =
nullptr;
480 prev->next = other_it->next;
481 other_it->next->prev = prev;
483 current = other_it->current =
nullptr;
484 next = other_it->next;
485 other_it->prev = prev;
487 return end_of_new_list;
void internal_clear(void(*zapper)(ELIST2_LINK *))
void exchange(ELIST2_ITERATOR *other_it)
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
ELIST2_LINK * data_relative(int8_t offset)
void add_before_then_move(ELIST2_LINK *new_link)
const ERRCODE BAD_PARAMETER
void add_sorted(int comparator(const void *, const void *), ELIST2_LINK *new_link)
void sort(int comparator(const void *, const void *))
void add_to_end(ELIST2_LINK *new_link)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const