82 "Destination list must be empty before extracting a sublist";
92 last = start_it->extract_sublist (end_it);
128 const void *,
const void *)) {
152 qsort ((
char *) base, count,
sizeof (*base), comparator);
156 for (i = 0; i <
count; i++) {
174 int comparator(
const void*,
const void*),
177 if (last ==
NULL || comparator(&last, &new_link) < 0) {
179 new_link->next = new_link;
181 new_link->next = last->next;
182 last->next = new_link;
190 int compare = comparator(&link, &new_link);
193 }
else if (unique && compare == 0) {
230 started_cycling =
TRUE;
232 current = current->next;
234 if (ex_current_was_cycle_pt)
238 next = current->next;
245 "This is: %p Current is: %p",
this, current);
278 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
305 while (current != list->last)
324 const ERRCODE DONT_EXCHANGE_DELETED =
325 "Can't exchange deleted elements of lists";
336 if (!(other_it->list))
343 if ((list->
empty ()) ||
344 (other_it->list->
empty ()) || (current == other_it->current))
349 if (!current || !other_it->current)
350 DONT_EXCHANGE_DELETED.
error (
"ELIST_ITERATOR.exchange",
ABORT,
NULL);
357 if ((next == other_it->current) ||
358 (other_it->next == current)) {
360 if ((next == other_it->current) &&
361 (other_it->next == current)) {
362 prev = next = current;
363 other_it->prev = other_it->next = other_it->current;
368 if (other_it->next == current) {
369 other_it->prev->next = current;
370 other_it->current->next = next;
371 current->next = other_it->current;
372 other_it->next = other_it->current;
376 prev->next = other_it->current;
377 current->next = other_it->next;
378 other_it->current->next = current;
380 other_it->prev = other_it->current;
385 prev->next = other_it->current;
386 current->next = other_it->next;
387 other_it->prev->next = current;
388 other_it->current->next = next;
394 if (list->last == current)
395 list->last = other_it->current;
396 if (other_it->list->last == other_it->current)
397 other_it->list->last = current;
399 if (current == cycle_pt)
400 cycle_pt = other_it->cycle_pt;
401 if (other_it->current == other_it->cycle_pt)
402 other_it->cycle_pt = cycle_pt;
406 old_current = current;
407 current = other_it->current;
408 other_it->current = old_current;
425 const ERRCODE BAD_EXTRACTION_PTS =
426 "Can't extract sublist from points on different lists";
427 const ERRCODE DONT_EXTRACT_DELETED =
428 "Can't extract a sublist marked by deleted points";
430 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
443 if (list != other_it->list)
444 BAD_EXTRACTION_PTS.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
NULL);
448 if (!current || !other_it->current)
449 DONT_EXTRACT_DELETED.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
453 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
454 ex_current_was_cycle_pt =
FALSE;
455 other_it->ex_current_was_cycle_pt =
FALSE;
460 BAD_SUBLIST.
error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
NULL);
464 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
467 if (temp_it.current == cycle_pt)
468 ex_current_was_cycle_pt =
TRUE;
470 if (temp_it.current == other_it->cycle_pt)
471 other_it->ex_current_was_cycle_pt =
TRUE;
475 while (temp_it.prev != other_it->current);
478 other_it->current->next = current;
479 end_of_new_list = other_it->current;
482 if (prev == other_it->current) {
484 prev = current = next =
NULL;
485 other_it->prev = other_it->current = other_it->next =
NULL;
488 prev->next = other_it->next;
489 current = other_it->current =
NULL;
490 next = other_it->next;
491 other_it->prev = prev;
493 return end_of_new_list;