74 constexpr
ERRCODE LIST_NOT_EMPTY(
75 "Destination list must be empty before extracting a sublist");
78 LIST_NOT_EMPTY.error (
"ELIST.assign_to_sublist",
ABORT,
nullptr);
80 last = start_it->extract_sublist (end_it);
109 const void *,
const void *)) {
118 base = static_cast<ELIST_LINK **>(malloc (
count *
sizeof (
ELIST_LINK *)));
128 qsort(base,
count,
sizeof(*base), comparator);
132 for (i = 0; i <
count; i++) {
150 int comparator(
const void*,
const void*),
153 if (last ==
nullptr || comparator(&last, &new_link) < 0) {
154 if (last ==
nullptr) {
155 new_link->next = new_link;
157 new_link->next = last->next;
158 last->next = new_link;
166 int compare = comparator(&link, &new_link);
169 }
else if (unique && compare == 0) {
204 started_cycling =
true;
206 current = current->next;
208 if (ex_current_was_cycle_pt)
216 next = current->next;
221 "This is: %p Current is: %p",
this, current);
251 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
275 while (current != list->last)
293 constexpr
ERRCODE DONT_EXCHANGE_DELETED(
294 "Can't exchange deleted elements of lists");
303 if (!(other_it->list))
310 if ((list->
empty ()) ||
311 (other_it->list->
empty ()) || (current == other_it->current))
316 if (!current || !other_it->current)
317 DONT_EXCHANGE_DELETED.error (
"ELIST_ITERATOR.exchange",
ABORT,
nullptr);
324 if ((next == other_it->current) ||
325 (other_it->next == current)) {
327 if ((next == other_it->current) &&
328 (other_it->next == current)) {
329 prev = next = current;
330 other_it->prev = other_it->next = other_it->current;
335 if (other_it->next == current) {
336 other_it->prev->next = current;
337 other_it->current->next = next;
338 current->next = other_it->current;
339 other_it->next = other_it->current;
343 prev->next = other_it->current;
344 current->next = other_it->next;
345 other_it->current->next = current;
347 other_it->prev = other_it->current;
352 prev->next = other_it->current;
353 current->next = other_it->next;
354 other_it->prev->next = current;
355 other_it->current->next = next;
361 if (list->last == current)
362 list->last = other_it->current;
363 if (other_it->list->last == other_it->current)
364 other_it->list->last = current;
366 if (current == cycle_pt)
367 cycle_pt = other_it->cycle_pt;
368 if (other_it->current == other_it->cycle_pt)
369 other_it->cycle_pt = cycle_pt;
373 old_current = current;
374 current = other_it->current;
375 other_it->current = old_current;
391 constexpr
ERRCODE BAD_EXTRACTION_PTS(
392 "Can't extract sublist from points on different lists");
393 constexpr
ERRCODE DONT_EXTRACT_DELETED(
394 "Can't extract a sublist marked by deleted points");
396 constexpr
ERRCODE BAD_SUBLIST(
"Can't find sublist end point in original list");
407 if (list != other_it->list)
408 BAD_EXTRACTION_PTS.error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
412 if (!current || !other_it->current)
413 DONT_EXTRACT_DELETED.error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
417 ex_current_was_last = other_it->ex_current_was_last =
false;
418 ex_current_was_cycle_pt =
false;
419 other_it->ex_current_was_cycle_pt =
false;
424 BAD_SUBLIST.error (
"ELIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
428 ex_current_was_last = other_it->ex_current_was_last =
true;
431 if (temp_it.current == cycle_pt)
432 ex_current_was_cycle_pt =
true;
434 if (temp_it.current == other_it->cycle_pt)
435 other_it->ex_current_was_cycle_pt =
true;
439 while (temp_it.prev != other_it->current);
442 other_it->current->next = current;
443 end_of_new_list = other_it->current;
446 if (prev == other_it->current) {
447 list->last =
nullptr;
448 prev = current = next =
nullptr;
449 other_it->prev = other_it->current = other_it->next =
nullptr;
452 prev->next = other_it->next;
453 current = other_it->current =
nullptr;
454 next = other_it->next;
455 other_it->prev = prev;
457 return end_of_new_list;