41 void (*zapper) (
void *)) {
99 constexpr
ERRCODE LIST_NOT_EMPTY(
100 "Destination list must be empty before extracting a sublist");
103 LIST_NOT_EMPTY.error (
"CLIST.assign_to_sublist",
ABORT,
nullptr);
105 last = start_it->extract_sublist (end_it);
132 const void *,
const void *)) {
141 base = static_cast<void **>(malloc (
count *
sizeof (
void *)));
151 qsort(base,
count,
sizeof(*base), comparator);
155 for (i = 0; i <
count; i++) {
170 bool unique,
void* new_data) {
172 if (last ==
nullptr || comparator(&last->data, &new_data) < 0) {
174 new_element->data = new_data;
175 if (last ==
nullptr) {
176 new_element->next = new_element;
178 new_element->next = last->next;
179 last->next = new_element;
183 }
else if (!unique || last->data != new_data) {
187 void* data = it.
data();
188 if (data == new_data && unique)
190 if (comparator(&data, &new_data) > 0)
216 void* minu = m_it.
data();
217 void* subtra =
nullptr;
219 subtra = s_it.
data();
221 comparator(&subtra, &minu) < 0) {
223 subtra = s_it.
data();
226 if (subtra ==
nullptr || comparator(&subtra, &minu) != 0)
255 started_cycling =
true;
257 current = current->next;
259 if (ex_current_was_cycle_pt)
269 "This is: %p Current is: %p",
this, current);
272 next = current->next;
273 return current->data;
301 for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
325 while (current != list->last)
328 if (current ==
nullptr)
331 return current->data;
346 constexpr
ERRCODE DONT_EXCHANGE_DELETED(
347 "Can't exchange deleted elements of lists");
356 if (!(other_it->list))
363 if ((list->
empty ()) ||
364 (other_it->list->
empty ()) || (current == other_it->current))
369 if (!current || !other_it->current)
370 DONT_EXCHANGE_DELETED.error (
"CLIST_ITERATOR.exchange",
ABORT,
nullptr);
377 if ((next == other_it->current) ||
378 (other_it->next == current)) {
380 if ((next == other_it->current) &&
381 (other_it->next == current)) {
382 prev = next = current;
383 other_it->prev = other_it->next = other_it->current;
388 if (other_it->next == current) {
389 other_it->prev->next = current;
390 other_it->current->next = next;
391 current->next = other_it->current;
392 other_it->next = other_it->current;
396 prev->next = other_it->current;
397 current->next = other_it->next;
398 other_it->current->next = current;
400 other_it->prev = other_it->current;
405 prev->next = other_it->current;
406 current->next = other_it->next;
407 other_it->prev->next = current;
408 other_it->current->next = next;
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;
446 constexpr
ERRCODE BAD_SUBLIST(
"Can't find sublist end point in original list");
448 constexpr
ERRCODE BAD_EXTRACTION_PTS(
449 "Can't extract sublist from points on different lists");
450 constexpr
ERRCODE DONT_EXTRACT_DELETED(
451 "Can't extract a sublist marked by deleted points");
458 if (list != other_it->list)
459 BAD_EXTRACTION_PTS.error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
463 if (!current || !other_it->current)
464 DONT_EXTRACT_DELETED.error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
468 ex_current_was_last = other_it->ex_current_was_last =
false;
469 ex_current_was_cycle_pt =
false;
470 other_it->ex_current_was_cycle_pt =
false;
475 BAD_SUBLIST.error (
"CLIST_ITERATOR.extract_sublist",
ABORT,
nullptr);
479 ex_current_was_last = other_it->ex_current_was_last =
true;
482 if (temp_it.current == cycle_pt)
483 ex_current_was_cycle_pt =
true;
485 if (temp_it.current == other_it->cycle_pt)
486 other_it->ex_current_was_cycle_pt =
true;
490 while (temp_it.prev != other_it->current);
493 other_it->current->next = current;
494 end_of_new_list = other_it->current;
497 if (prev == other_it->current) {
498 list->last =
nullptr;
499 prev = current = next =
nullptr;
500 other_it->prev = other_it->current = other_it->next =
nullptr;
503 prev->next = other_it->next;
504 current = other_it->current =
nullptr;
505 next = other_it->next;
506 other_it->prev = prev;
508 return end_of_new_list;