43 void (*zapper) (
void *)) {
113 "Destination list must be empty before extracting a sublist";
123 last = start_it->extract_sublist (end_it);
157 const void *,
const void *)) {
171 base = (
void **) malloc (count *
sizeof (
void *));
181 qsort ((
char *) base, count,
sizeof (*base), comparator);
185 for (i = 0; i <
count; i++) {
200 bool unique,
void* new_data) {
202 if (last ==
NULL || comparator(&last->data, &new_data) < 0) {
204 new_element->data = new_data;
206 new_element->next = new_element;
208 new_element->next = last->next;
209 last->next = new_element;
213 }
else if (!unique || last->data != new_data) {
217 void* data = it.
data();
218 if (data == new_data && unique)
220 if (comparator(&data, &new_data) > 0)
246 void* minu = m_it.
data();
249 subtra = s_it.
data();
251 comparator(&subtra, &minu) < 0) {
253 subtra = s_it.
data();
256 if (subtra ==
NULL || comparator(&subtra, &minu) != 0)
287 started_cycling =
TRUE;
289 current = current->next;
291 if (ex_current_was_cycle_pt)
295 next = current->next;
302 "This is: %p Current is: %p",
this, current);
304 return current->data;
335 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
362 while (current != list->last)
368 return current->data;
384 const ERRCODE DONT_EXCHANGE_DELETED =
385 "Can't exchange deleted elements of lists";
396 if (!(other_it->list))
403 if ((list->
empty ()) ||
404 (other_it->list->
empty ()) || (current == other_it->current))
409 if (!current || !other_it->current)
410 DONT_EXCHANGE_DELETED.
error (
"CLIST_ITERATOR.exchange",
ABORT,
NULL);
417 if ((next == other_it->current) ||
418 (other_it->next == current)) {
420 if ((next == other_it->current) &&
421 (other_it->next == current)) {
422 prev = next = current;
423 other_it->prev = other_it->next = other_it->current;
428 if (other_it->next == current) {
429 other_it->prev->next = current;
430 other_it->current->next = next;
431 current->next = other_it->current;
432 other_it->next = other_it->current;
436 prev->next = other_it->current;
437 current->next = other_it->next;
438 other_it->current->next = current;
440 other_it->prev = other_it->current;
445 prev->next = other_it->current;
446 current->next = other_it->next;
447 other_it->prev->next = current;
448 other_it->current->next = next;
454 if (list->last == current)
455 list->last = other_it->current;
456 if (other_it->list->last == other_it->current)
457 other_it->list->last = current;
459 if (current == cycle_pt)
460 cycle_pt = other_it->cycle_pt;
461 if (other_it->current == other_it->cycle_pt)
462 other_it->cycle_pt = cycle_pt;
466 old_current = current;
467 current = other_it->current;
468 other_it->current = old_current;
487 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
489 const ERRCODE BAD_EXTRACTION_PTS =
490 "Can't extract sublist from points on different lists";
491 const ERRCODE DONT_EXTRACT_DELETED =
492 "Can't extract a sublist marked by deleted points";
501 if (list != other_it->list)
502 BAD_EXTRACTION_PTS.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
NULL);
506 if (!current || !other_it->current)
507 DONT_EXTRACT_DELETED.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
511 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
512 ex_current_was_cycle_pt =
FALSE;
513 other_it->ex_current_was_cycle_pt =
FALSE;
518 BAD_SUBLIST.
error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
NULL);
522 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
525 if (temp_it.current == cycle_pt)
526 ex_current_was_cycle_pt =
TRUE;
528 if (temp_it.current == other_it->cycle_pt)
529 other_it->ex_current_was_cycle_pt =
TRUE;
533 while (temp_it.prev != other_it->current);
536 other_it->current->next = current;
537 end_of_new_list = other_it->current;
540 if (prev == other_it->current) {
542 prev = current = next =
NULL;
543 other_it->prev = other_it->current = other_it->next =
NULL;
546 prev->next = other_it->next;
547 current = other_it->current =
NULL;
548 next = other_it->next;
549 other_it->prev = prev;
551 return end_of_new_list;