82 "Destination list must be empty before extracting a sublist";
92 last = start_it->extract_sublist (end_it);
128 const void *,
const void *)) {
152 qsort ((
char *) base, count,
sizeof (*base), comparator);
156 for (i = 0; i <
count; i++) {
171 if (last ==
NULL || comparator(&last, &new_link) < 0) {
173 new_link->next = new_link;
174 new_link->prev = new_link;
176 new_link->next = last->next;
177 new_link->prev = last;
178 last->next = new_link;
179 new_link->next->prev = new_link;
187 if (comparator(&link, &new_link) > 0)
222 started_cycling =
TRUE;
224 current = current->next;
227 if (ex_current_was_cycle_pt)
231 next = current->next;
238 "This is: %p Current is: %p",
this, current);
264 started_cycling =
TRUE;
266 current = current->prev;
268 if (ex_current_was_cycle_pt)
272 prev = current->prev;
279 "This is: %p Current is: %p",
this, current);
306 for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);
308 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
331 const ERRCODE DONT_EXCHANGE_DELETED =
332 "Can't exchange deleted elements of lists";
343 if (!(other_it->list))
350 if ((list->
empty ()) ||
351 (other_it->list->
empty ()) || (current == other_it->current))
356 if (!current || !other_it->current)
357 DONT_EXCHANGE_DELETED.
error (
"ELIST2_ITERATOR.exchange",
ABORT,
NULL);
364 if ((next == other_it->current) ||
365 (other_it->next == current)) {
367 if ((next == other_it->current) &&
368 (other_it->next == current)) {
369 prev = next = current;
370 other_it->prev = other_it->next = other_it->current;
375 if (other_it->next == current) {
376 other_it->prev->next = current;
377 other_it->current->next = next;
378 other_it->current->prev = current;
379 current->next = other_it->current;
380 current->prev = other_it->prev;
381 next->prev = other_it->current;
383 other_it->next = other_it->current;
387 prev->next = other_it->current;
388 current->next = other_it->next;
389 current->prev = other_it->current;
390 other_it->current->next = current;
391 other_it->current->prev = prev;
392 other_it->next->prev = current;
395 other_it->prev = other_it->current;
400 prev->next = other_it->current;
401 current->next = other_it->next;
402 current->prev = other_it->prev;
403 next->prev = other_it->current;
404 other_it->prev->next = current;
405 other_it->current->next = next;
406 other_it->current->prev = prev;
407 other_it->next->prev = current;
413 if (list->last == current)
414 list->last = other_it->current;
415 if (other_it->list->last == other_it->current)
416 other_it->list->last = current;
418 if (current == cycle_pt)
419 cycle_pt = other_it->cycle_pt;
420 if (other_it->current == other_it->cycle_pt)
421 other_it->cycle_pt = cycle_pt;
425 old_current = current;
426 current = other_it->current;
427 other_it->current = old_current;
444 const ERRCODE BAD_EXTRACTION_PTS =
445 "Can't extract sublist from points on different lists";
446 const ERRCODE DONT_EXTRACT_DELETED =
447 "Can't extract a sublist marked by deleted points";
449 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
462 if (list != other_it->list)
463 BAD_EXTRACTION_PTS.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
NULL);
467 if (!current || !other_it->current)
468 DONT_EXTRACT_DELETED.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
472 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
473 ex_current_was_cycle_pt =
FALSE;
474 other_it->ex_current_was_cycle_pt =
FALSE;
479 BAD_SUBLIST.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
NULL);
483 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
486 if (temp_it.current == cycle_pt)
487 ex_current_was_cycle_pt =
TRUE;
489 if (temp_it.current == other_it->cycle_pt)
490 other_it->ex_current_was_cycle_pt =
TRUE;
495 while (temp_it.prev != other_it->current);
498 other_it->current->next = current;
500 current->prev = other_it->current;
501 end_of_new_list = other_it->current;
504 if (prev == other_it->current) {
506 prev = current = next =
NULL;
507 other_it->prev = other_it->current = other_it->next =
NULL;
510 prev->next = other_it->next;
511 other_it->next->prev = prev;
513 current = other_it->current =
NULL;
514 next = other_it->next;
515 other_it->prev = prev;
517 return end_of_new_list;
void internal_clear(void(*zapper)(ELIST2_LINK *))
void add_sorted(int comparator(const void *, const void *), ELIST2_LINK *new_link)
void sort(int comparator(const void *, const void *))
void add_before_then_move(ELIST2_LINK *new_link)
const ERRCODE BAD_PARAMETER
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void exchange(ELIST2_ITERATOR *other_it)
const ERRCODE NULL_OBJECT
ELIST2_LINK * data_relative(inT8 offset)
void add_to_end(ELIST2_LINK *new_link)