42 void (*zapper) (
void *)) {
112 "Destination list must be empty before extracting a sublist";
122 last = start_it->extract_sublist (end_it);
156 const void *,
const void *)) {
170 base = (
void **) malloc (count *
sizeof (
void *));
180 qsort ((
char *) base, count,
sizeof (*base), comparator);
184 for (i = 0; i <
count; i++) {
199 bool unique,
void* new_data) {
201 if (last ==
NULL || comparator(&last->data, &new_data) < 0) {
203 new_element->data = new_data;
205 new_element->next = new_element;
207 new_element->next = last->next;
208 last->next = new_element;
212 }
else if (!unique || last->data != new_data) {
216 void* data = it.
data();
217 if (data == new_data && unique)
219 if (comparator(&data, &new_data) > 0)
245 void* minu = m_it.
data();
248 subtra = s_it.
data();
250 comparator(&subtra, &minu) < 0) {
252 subtra = s_it.
data();
255 if (subtra ==
NULL || comparator(&subtra, &minu) != 0)
286 started_cycling =
TRUE;
288 current = current->next;
290 if (ex_current_was_cycle_pt)
294 next = current->next;
301 "This is: %p Current is: %p",
this, current);
303 return current->data;
334 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
361 while (current != list->last)
367 return current->data;
383 const ERRCODE DONT_EXCHANGE_DELETED =
384 "Can't exchange deleted elements of lists";
395 if (!(other_it->list))
402 if ((list->
empty ()) ||
403 (other_it->list->
empty ()) || (current == other_it->current))
408 if (!current || !other_it->current)
409 DONT_EXCHANGE_DELETED.
error (
"CLIST_ITERATOR.exchange",
ABORT,
NULL);
416 if ((next == other_it->current) ||
417 (other_it->next == current)) {
419 if ((next == other_it->current) &&
420 (other_it->next == current)) {
421 prev = next = current;
422 other_it->prev = other_it->next = other_it->current;
427 if (other_it->next == current) {
428 other_it->prev->next = current;
429 other_it->current->next = next;
430 current->next = other_it->current;
431 other_it->next = other_it->current;
435 prev->next = other_it->current;
436 current->next = other_it->next;
437 other_it->current->next = current;
439 other_it->prev = other_it->current;
444 prev->next = other_it->current;
445 current->next = other_it->next;
446 other_it->prev->next = current;
447 other_it->current->next = next;
453 if (list->last == current)
454 list->last = other_it->current;
455 if (other_it->list->last == other_it->current)
456 other_it->list->last = current;
458 if (current == cycle_pt)
459 cycle_pt = other_it->cycle_pt;
460 if (other_it->current == other_it->cycle_pt)
461 other_it->cycle_pt = cycle_pt;
465 old_current = current;
466 current = other_it->current;
467 other_it->current = old_current;
486 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
488 const ERRCODE BAD_EXTRACTION_PTS =
489 "Can't extract sublist from points on different lists";
490 const ERRCODE DONT_EXTRACT_DELETED =
491 "Can't extract a sublist marked by deleted points";
500 if (list != other_it->list)
501 BAD_EXTRACTION_PTS.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
NULL);
505 if (!current || !other_it->current)
506 DONT_EXTRACT_DELETED.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
510 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
511 ex_current_was_cycle_pt =
FALSE;
512 other_it->ex_current_was_cycle_pt =
FALSE;
517 BAD_SUBLIST.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
NULL);
521 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
524 if (temp_it.current == cycle_pt)
525 ex_current_was_cycle_pt =
TRUE;
527 if (temp_it.current == other_it->cycle_pt)
528 other_it->ex_current_was_cycle_pt =
TRUE;
532 while (temp_it.prev != other_it->current);
535 other_it->current->next = current;
536 end_of_new_list = other_it->current;
539 if (prev == other_it->current) {
541 prev = current = next =
NULL;
542 other_it->prev = other_it->current = other_it->next =
NULL;
545 prev->next = other_it->next;
546 current = other_it->current =
NULL;
547 next = other_it->next;
548 other_it->prev = prev;
550 return end_of_new_list;
void exchange(CLIST_ITERATOR *other_it)
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
const ERRCODE BAD_PARAMETER
void set_subtract(int comparator(const void *, const void *), bool unique, CLIST *minuend, CLIST *subtrahend)
void * data_relative(inT8 offset)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void sort(int comparator(const void *, const void *))
void add_before_then_move(void *new_data)
void add_to_end(void *new_data)
void internal_deep_clear(void(*zapper)(void *))
bool add_sorted(int comparator(const void *, const void *), bool unique, void *new_data)
const ERRCODE NULL_OBJECT