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);
112 const void *,
const void *)) {
131 qsort ((
char *) base, count,
sizeof (*base), comparator);
135 for (i = 0; i <
count; i++) {
153 int comparator(
const void*,
const void*),
156 if (last == NULL || comparator(&last, &new_link) < 0) {
158 new_link->next = new_link;
160 new_link->next = last->next;
161 last->next = new_link;
169 int compare = comparator(&link, &new_link);
172 }
else if (unique && compare == 0) {
207 started_cycling =
TRUE;
209 current = current->next;
211 if (ex_current_was_cycle_pt)
215 next = current->next;
222 "This is: %p Current is: %p",
this, current);
253 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
278 while (current != list->last)
297 const ERRCODE DONT_EXCHANGE_DELETED =
298 "Can't exchange deleted elements of lists";
307 if (!(other_it->list))
314 if ((list->
empty ()) ||
315 (other_it->list->
empty ()) || (current == other_it->current))
320 if (!current || !other_it->current)
321 DONT_EXCHANGE_DELETED.
error (
"ELIST_ITERATOR.exchange",
ABORT, NULL);
328 if ((next == other_it->current) ||
329 (other_it->next == current)) {
331 if ((next == other_it->current) &&
332 (other_it->next == current)) {
333 prev = next = current;
334 other_it->prev = other_it->next = other_it->current;
339 if (other_it->next == current) {
340 other_it->prev->next = current;
341 other_it->current->next = next;
342 current->next = other_it->current;
343 other_it->next = other_it->current;
347 prev->next = other_it->current;
348 current->next = other_it->next;
349 other_it->current->next = current;
351 other_it->prev = other_it->current;
356 prev->next = other_it->current;
357 current->next = other_it->next;
358 other_it->prev->next = current;
359 other_it->current->next = next;
365 if (list->last == current)
366 list->last = other_it->current;
367 if (other_it->list->last == other_it->current)
368 other_it->list->last = current;
370 if (current == cycle_pt)
371 cycle_pt = other_it->cycle_pt;
372 if (other_it->current == other_it->cycle_pt)
373 other_it->cycle_pt = cycle_pt;
377 old_current = current;
378 current = other_it->current;
379 other_it->current = old_current;
396 const ERRCODE BAD_EXTRACTION_PTS =
397 "Can't extract sublist from points on different lists";
398 const ERRCODE DONT_EXTRACT_DELETED =
399 "Can't extract a sublist marked by deleted points";
401 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
412 if (list != other_it->list)
413 BAD_EXTRACTION_PTS.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT, NULL);
417 if (!current || !other_it->current)
418 DONT_EXTRACT_DELETED.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
422 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
423 ex_current_was_cycle_pt =
FALSE;
424 other_it->ex_current_was_cycle_pt =
FALSE;
429 BAD_SUBLIST.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT, NULL);
433 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
436 if (temp_it.current == cycle_pt)
437 ex_current_was_cycle_pt =
TRUE;
439 if (temp_it.current == other_it->cycle_pt)
440 other_it->ex_current_was_cycle_pt =
TRUE;
444 while (temp_it.prev != other_it->current);
447 other_it->current->next = current;
448 end_of_new_list = other_it->current;
451 if (prev == other_it->current) {
453 prev = current = next = NULL;
454 other_it->prev = other_it->current = other_it->next = NULL;
457 prev->next = other_it->next;
458 current = other_it->current = NULL;
459 next = other_it->next;
460 other_it->prev = prev;
462 return end_of_new_list;
void add_to_end(ELIST_LINK *new_link)
void sort(int comparator(const void *, const void *))
ELIST_LINK * data_relative(inT8 offset)
const ERRCODE BAD_PARAMETER
void exchange(ELIST_ITERATOR *other_it)
void add_before_then_move(ELIST_LINK *new_link)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
ELIST_LINK * add_sorted_and_find(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
ELIST_LINK * move_to_last()
void internal_clear(void(*zapper)(ELIST_LINK *))
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)