76 "Destination list must be empty before extracting a sublist";
79 LIST_NOT_EMPTY.
error (
"ELIST.assign_to_sublist",
ABORT, NULL);
81 last = start_it->extract_sublist (end_it);
110 const void *,
const void *)) {
129 qsort ((
char *) base,
count,
sizeof (*base), comparator);
133 for (i = 0; i <
count; i++) {
151 int comparator(
const void*,
const void*),
154 if (last == NULL || comparator(&last, &new_link) < 0) {
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)
213 next = current->next;
220 "This is: %p Current is: %p",
this, current);
250 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
274 while (current != list->last)
292 const ERRCODE DONT_EXCHANGE_DELETED =
293 "Can't exchange deleted elements of lists";
302 if (!(other_it->list))
309 if ((list->
empty ()) ||
310 (other_it->list->
empty ()) || (current == other_it->current))
315 if (!current || !other_it->current)
316 DONT_EXCHANGE_DELETED.
error (
"ELIST_ITERATOR.exchange",
ABORT, NULL);
323 if ((next == other_it->current) ||
324 (other_it->next == current)) {
326 if ((next == other_it->current) &&
327 (other_it->next == current)) {
328 prev = next = current;
329 other_it->prev = other_it->next = other_it->current;
334 if (other_it->next == current) {
335 other_it->prev->next = current;
336 other_it->current->next = next;
337 current->next = other_it->current;
338 other_it->next = other_it->current;
342 prev->next = other_it->current;
343 current->next = other_it->next;
344 other_it->current->next = current;
346 other_it->prev = other_it->current;
351 prev->next = other_it->current;
352 current->next = other_it->next;
353 other_it->prev->next = current;
354 other_it->current->next = next;
360 if (list->last == current)
361 list->last = other_it->current;
362 if (other_it->list->last == other_it->current)
363 other_it->list->last = current;
365 if (current == cycle_pt)
366 cycle_pt = other_it->cycle_pt;
367 if (other_it->current == other_it->cycle_pt)
368 other_it->cycle_pt = cycle_pt;
372 old_current = current;
373 current = other_it->current;
374 other_it->current = old_current;
390 const ERRCODE BAD_EXTRACTION_PTS =
391 "Can't extract sublist from points on different lists";
392 const ERRCODE DONT_EXTRACT_DELETED =
393 "Can't extract a sublist marked by deleted points";
395 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
406 if (list != other_it->list)
407 BAD_EXTRACTION_PTS.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT, NULL);
411 if (!current || !other_it->current)
412 DONT_EXTRACT_DELETED.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
416 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
417 ex_current_was_cycle_pt =
FALSE;
418 other_it->ex_current_was_cycle_pt =
FALSE;
423 BAD_SUBLIST.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT, NULL);
427 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
430 if (temp_it.current == cycle_pt)
431 ex_current_was_cycle_pt =
TRUE;
433 if (temp_it.current == other_it->cycle_pt)
434 other_it->ex_current_was_cycle_pt =
TRUE;
438 while (temp_it.prev != other_it->current);
441 other_it->current->next = current;
442 end_of_new_list = other_it->current;
445 if (prev == other_it->current) {
447 prev = current = next = NULL;
448 other_it->prev = other_it->current = other_it->next = NULL;
451 prev->next = other_it->next;
452 current = other_it->current = NULL;
453 next = other_it->next;
454 other_it->prev = prev;
456 return end_of_new_list;
const ERRCODE BAD_PARAMETER
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)
void sort(int comparator(const void *, const void *))
void internal_clear(void(*zapper)(ELIST_LINK *))
ELIST_LINK * add_sorted_and_find(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
ELIST_LINK * move_to_last()
ELIST_LINK * data_relative(inT8 offset)
void exchange(ELIST_ITERATOR *other_it)
void add_to_end(ELIST_LINK *new_link)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void add_before_then_move(ELIST_LINK *new_link)