42 void (*zapper) (
void *)) {
101 "Destination list must be empty before extracting a sublist";
104 LIST_NOT_EMPTY.
error (
"CLIST.assign_to_sublist",
ABORT, NULL);
106 last = start_it->extract_sublist (end_it);
133 const void *,
const void *)) {
142 base = (
void **) malloc (
count *
sizeof (
void *));
152 qsort ((
char *) base,
count,
sizeof (*base), comparator);
156 for (i = 0; i <
count; i++) {
171 bool unique,
void* new_data) {
173 if (last == NULL || comparator(&last->data, &new_data) < 0) {
175 new_element->data = new_data;
177 new_element->next = new_element;
179 new_element->next = last->next;
180 last->next = new_element;
184 }
else if (!unique || last->data != new_data) {
188 void* data = it.
data();
189 if (data == new_data && unique)
191 if (comparator(&data, &new_data) > 0)
217 void* minu = m_it.
data();
220 subtra = s_it.
data();
222 comparator(&subtra, &minu) < 0) {
224 subtra = s_it.
data();
227 if (subtra == NULL || comparator(&subtra, &minu) != 0)
256 started_cycling =
TRUE;
258 current = current->next;
260 if (ex_current_was_cycle_pt)
264 next = current->next;
271 "This is: %p Current is: %p",
this, current);
273 return current->data;
301 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
325 while (current != list->last)
331 return current->data;
346 const ERRCODE DONT_EXCHANGE_DELETED =
347 "Can't exchange deleted elements of lists";
356 if (!(other_it->list))
363 if ((list->
empty ()) ||
364 (other_it->list->
empty ()) || (current == other_it->current))
369 if (!current || !other_it->current)
370 DONT_EXCHANGE_DELETED.
error (
"CLIST_ITERATOR.exchange",
ABORT, NULL);
377 if ((next == other_it->current) ||
378 (other_it->next == current)) {
380 if ((next == other_it->current) &&
381 (other_it->next == current)) {
382 prev = next = current;
383 other_it->prev = other_it->next = other_it->current;
388 if (other_it->next == current) {
389 other_it->prev->next = current;
390 other_it->current->next = next;
391 current->next = other_it->current;
392 other_it->next = other_it->current;
396 prev->next = other_it->current;
397 current->next = other_it->next;
398 other_it->current->next = current;
400 other_it->prev = other_it->current;
405 prev->next = other_it->current;
406 current->next = other_it->next;
407 other_it->prev->next = current;
408 other_it->current->next = next;
414 if (list->last == current)
415 list->last = other_it->current;
416 if (other_it->list->last == other_it->current)
417 other_it->list->last = current;
419 if (current == cycle_pt)
420 cycle_pt = other_it->cycle_pt;
421 if (other_it->current == other_it->cycle_pt)
422 other_it->cycle_pt = cycle_pt;
426 old_current = current;
427 current = other_it->current;
428 other_it->current = old_current;
446 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
448 const ERRCODE BAD_EXTRACTION_PTS =
449 "Can't extract sublist from points on different lists";
450 const ERRCODE DONT_EXTRACT_DELETED =
451 "Can't extract a sublist marked by deleted points";
458 if (list != other_it->list)
459 BAD_EXTRACTION_PTS.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT, NULL);
463 if (!current || !other_it->current)
464 DONT_EXTRACT_DELETED.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
468 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
469 ex_current_was_cycle_pt =
FALSE;
470 other_it->ex_current_was_cycle_pt =
FALSE;
475 BAD_SUBLIST.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT, NULL);
479 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
482 if (temp_it.current == cycle_pt)
483 ex_current_was_cycle_pt =
TRUE;
485 if (temp_it.current == other_it->cycle_pt)
486 other_it->ex_current_was_cycle_pt =
TRUE;
490 while (temp_it.prev != other_it->current);
493 other_it->current->next = current;
494 end_of_new_list = other_it->current;
497 if (prev == other_it->current) {
499 prev = current = next = NULL;
500 other_it->prev = other_it->current = other_it->next = NULL;
503 prev->next = other_it->next;
504 current = other_it->current = NULL;
505 next = other_it->next;
506 other_it->prev = prev;
508 return end_of_new_list;
const ERRCODE BAD_PARAMETER
void exchange(CLIST_ITERATOR *other_it)
void * data_relative(inT8 offset)
void internal_deep_clear(void(*zapper)(void *))
void set_subtract(int comparator(const void *, const void *), bool unique, CLIST *minuend, CLIST *subtrahend)
void add_to_end(void *new_data)
void add_before_then_move(void *new_data)
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
bool add_sorted(int comparator(const void *, const void *), bool unique, void *new_data)
void sort(int comparator(const void *, const void *))