83 "Destination list must be empty before extracting a sublist";
93 last = start_it->extract_sublist (end_it);
129 const void *,
const void *)) {
153 qsort ((
char *) base, count,
sizeof (*base), comparator);
157 for (i = 0; i <
count; i++) {
172 if (last ==
NULL || comparator(&last, &new_link) < 0) {
174 new_link->next = new_link;
175 new_link->prev = new_link;
177 new_link->next = last->next;
178 new_link->prev = last;
179 last->next = new_link;
180 new_link->next->prev = new_link;
188 if (comparator(&link, &new_link) > 0)
223 started_cycling =
TRUE;
225 current = current->next;
228 if (ex_current_was_cycle_pt)
232 next = current->next;
239 "This is: %p Current is: %p",
this, current);
265 started_cycling =
TRUE;
267 current = current->prev;
269 if (ex_current_was_cycle_pt)
273 prev = current->prev;
280 "This is: %p Current is: %p",
this, current);
307 for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);
309 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
332 const ERRCODE DONT_EXCHANGE_DELETED =
333 "Can't exchange deleted elements of lists";
344 if (!(other_it->list))
351 if ((list->
empty ()) ||
352 (other_it->list->
empty ()) || (current == other_it->current))
357 if (!current || !other_it->current)
358 DONT_EXCHANGE_DELETED.
error (
"ELIST2_ITERATOR.exchange",
ABORT,
NULL);
365 if ((next == other_it->current) ||
366 (other_it->next == current)) {
368 if ((next == other_it->current) &&
369 (other_it->next == current)) {
370 prev = next = current;
371 other_it->prev = other_it->next = other_it->current;
376 if (other_it->next == current) {
377 other_it->prev->next = current;
378 other_it->current->next = next;
379 other_it->current->prev = current;
380 current->next = other_it->current;
381 current->prev = other_it->prev;
382 next->prev = other_it->current;
384 other_it->next = other_it->current;
388 prev->next = other_it->current;
389 current->next = other_it->next;
390 current->prev = other_it->current;
391 other_it->current->next = current;
392 other_it->current->prev = prev;
393 other_it->next->prev = current;
396 other_it->prev = other_it->current;
401 prev->next = other_it->current;
402 current->next = other_it->next;
403 current->prev = other_it->prev;
404 next->prev = other_it->current;
405 other_it->prev->next = current;
406 other_it->current->next = next;
407 other_it->current->prev = prev;
408 other_it->next->prev = current;
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;
445 const ERRCODE BAD_EXTRACTION_PTS =
446 "Can't extract sublist from points on different lists";
447 const ERRCODE DONT_EXTRACT_DELETED =
448 "Can't extract a sublist marked by deleted points";
450 const ERRCODE BAD_SUBLIST =
"Can't find sublist end point in original list";
463 if (list != other_it->list)
464 BAD_EXTRACTION_PTS.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
NULL);
468 if (!current || !other_it->current)
469 DONT_EXTRACT_DELETED.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
473 ex_current_was_last = other_it->ex_current_was_last =
FALSE;
474 ex_current_was_cycle_pt =
FALSE;
475 other_it->ex_current_was_cycle_pt =
FALSE;
480 BAD_SUBLIST.
error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
NULL);
484 ex_current_was_last = other_it->ex_current_was_last =
TRUE;
487 if (temp_it.current == cycle_pt)
488 ex_current_was_cycle_pt =
TRUE;
490 if (temp_it.current == other_it->cycle_pt)
491 other_it->ex_current_was_cycle_pt =
TRUE;
496 while (temp_it.prev != other_it->current);
499 other_it->current->next = current;
501 current->prev = other_it->current;
502 end_of_new_list = other_it->current;
505 if (prev == other_it->current) {
507 prev = current = next =
NULL;
508 other_it->prev = other_it->current = other_it->next =
NULL;
511 prev->next = other_it->next;
512 other_it->next->prev = prev;
514 current = other_it->current =
NULL;
515 next = other_it->next;
516 other_it->prev = prev;
518 return end_of_new_list;