74 constexpr
ERRCODE LIST_NOT_EMPTY(
75 "Destination list must be empty before extracting a sublist");
78 LIST_NOT_EMPTY.error (
"ELIST2.assign_to_sublist",
ABORT,
nullptr);
80 last = start_it->extract_sublist (end_it);
109 const void *,
const void *)) {
118 base = static_cast<ELIST2_LINK **>(malloc (
count *
sizeof (
ELIST2_LINK *)));
128 qsort(base,
count,
sizeof(*base), comparator);
132 for (i = 0; i <
count; i++) {
147 if (last ==
nullptr || comparator(&last, &new_link) < 0) {
148 if (last ==
nullptr) {
149 new_link->next = new_link;
150 new_link->prev = new_link;
152 new_link->next = last->next;
153 new_link->prev = last;
154 last->next = new_link;
155 new_link->next->prev = new_link;
163 if (comparator(&link, &new_link) > 0)
196 started_cycling =
true;
198 current = current->next;
201 if (ex_current_was_cycle_pt)
211 next = current->next;
216 "This is: %p Current is: %p",
this, current);
240 started_cycling =
true;
242 current = current->prev;
244 if (ex_current_was_cycle_pt)
254 "This is: %p Current is: %p",
this, current);
257 prev = current->prev;
280 for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);
282 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
304 constexpr
ERRCODE DONT_EXCHANGE_DELETED(
305 "Can't exchange deleted elements of lists");
314 if (!(other_it->list))
321 if ((list->
empty ()) ||
322 (other_it->list->
empty ()) || (current == other_it->current))
327 if (!current || !other_it->current)
328 DONT_EXCHANGE_DELETED.error (
"ELIST2_ITERATOR.exchange",
ABORT,
nullptr);
335 if ((next == other_it->current) ||
336 (other_it->next == current)) {
338 if ((next == other_it->current) &&
339 (other_it->next == current)) {
340 prev = next = current;
341 other_it->prev = other_it->next = other_it->current;
346 if (other_it->next == current) {
347 other_it->prev->next = current;
348 other_it->current->next = next;
349 other_it->current->prev = current;
350 current->next = other_it->current;
351 current->prev = other_it->prev;
352 next->prev = other_it->current;
354 other_it->next = other_it->current;
358 prev->next = other_it->current;
359 current->next = other_it->next;
360 current->prev = other_it->current;
361 other_it->current->next = current;
362 other_it->current->prev = prev;
363 other_it->next->prev = current;
366 other_it->prev = other_it->current;
371 prev->next = other_it->current;
372 current->next = other_it->next;
373 current->prev = other_it->prev;
374 next->prev = other_it->current;
375 other_it->prev->next = current;
376 other_it->current->next = next;
377 other_it->current->prev = prev;
378 other_it->next->prev = current;
384 if (list->last == current)
385 list->last = other_it->current;
386 if (other_it->list->last == other_it->current)
387 other_it->list->last = current;
389 if (current == cycle_pt)
390 cycle_pt = other_it->cycle_pt;
391 if (other_it->current == other_it->cycle_pt)
392 other_it->cycle_pt = cycle_pt;
396 old_current = current;
397 current = other_it->current;
398 other_it->current = old_current;
414 constexpr
ERRCODE BAD_EXTRACTION_PTS(
415 "Can't extract sublist from points on different lists");
416 constexpr
ERRCODE DONT_EXTRACT_DELETED(
417 "Can't extract a sublist marked by deleted points");
419 constexpr
ERRCODE BAD_SUBLIST(
"Can't find sublist end point in original list");
430 if (list != other_it->list)
431 BAD_EXTRACTION_PTS.error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
nullptr);
435 if (!current || !other_it->current)
436 DONT_EXTRACT_DELETED.error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
440 ex_current_was_last = other_it->ex_current_was_last =
false;
441 ex_current_was_cycle_pt =
false;
442 other_it->ex_current_was_cycle_pt =
false;
447 BAD_SUBLIST.error (
"ELIST2_ITERATOR.extract_sublist",
ABORT,
nullptr);
451 ex_current_was_last = other_it->ex_current_was_last =
true;
454 if (temp_it.current == cycle_pt)
455 ex_current_was_cycle_pt =
true;
457 if (temp_it.current == other_it->cycle_pt)
458 other_it->ex_current_was_cycle_pt =
true;
463 while (temp_it.prev != other_it->current);
466 other_it->current->next = current;
468 current->prev = other_it->current;
469 end_of_new_list = other_it->current;
472 if (prev == other_it->current) {
473 list->last =
nullptr;
474 prev = current = next =
nullptr;
475 other_it->prev = other_it->current = other_it->next =
nullptr;
478 prev->next = other_it->next;
479 other_it->next->prev = prev;
481 current = other_it->current =
nullptr;
482 next = other_it->next;
483 other_it->prev = prev;
485 return end_of_new_list;