66 prev = next =
nullptr;
71 prev = next =
nullptr;
76 prev = next =
nullptr;
101 void internal_clear (
109 bool singleton()
const {
115 last = from_list->last;
122 void assign_to_sublist(
130 const void *,
const void *));
137 void add_sorted(
int comparator(
const void*,
const void*),
158 bool ex_current_was_last;
159 bool ex_current_was_cycle_pt;
160 bool started_cycling;
172 void add_after_then_move(
175 void add_after_stay_put(
178 void add_before_then_move(
181 void add_before_stay_put(
187 void add_list_before(
214 void mark_cycle_pt();
221 return list->
empty ();
224 bool current_extracted() {
244 const void *,
const void *));
259 ELIST2 *list_to_iterate) {
261 if (!list_to_iterate)
263 "list_to_iterate is nullptr");
266 list = list_to_iterate;
268 current = list->First ();
269 next = current ? current->next :
nullptr;
271 started_cycling =
false;
272 ex_current_was_last =
false;
273 ex_current_was_cycle_pt =
false;
300 "new_element is nullptr");
301 if (new_element->next)
305 if (list->
empty ()) {
306 new_element->next = new_element;
307 new_element->prev = new_element;
308 list->last = new_element;
309 prev = next = new_element;
312 new_element->next = next;
313 next->prev = new_element;
316 new_element->prev = current;
317 current->next = new_element;
319 if (current == list->last)
320 list->last = new_element;
323 new_element->prev = prev;
324 prev->next = new_element;
325 if (ex_current_was_last)
326 list->last = new_element;
327 if (ex_current_was_cycle_pt)
328 cycle_pt = new_element;
331 current = new_element;
348 "new_element is nullptr");
349 if (new_element->next)
353 if (list->
empty ()) {
354 new_element->next = new_element;
355 new_element->prev = new_element;
356 list->last = new_element;
357 prev = next = new_element;
358 ex_current_was_last =
false;
362 new_element->next = next;
363 next->prev = new_element;
366 new_element->prev = current;
367 current->next = new_element;
370 if (current == list->last)
371 list->last = new_element;
374 new_element->prev = prev;
375 prev->next = new_element;
376 if (ex_current_was_last) {
377 list->last = new_element;
378 ex_current_was_last =
false;
399 "new_element is nullptr");
400 if (new_element->next)
404 if (list->
empty ()) {
405 new_element->next = new_element;
406 new_element->prev = new_element;
407 list->last = new_element;
408 prev = next = new_element;
411 prev->next = new_element;
412 new_element->prev = prev;
415 new_element->next = current;
416 current->prev = new_element;
420 new_element->next = next;
421 next->prev = new_element;
422 if (ex_current_was_last)
423 list->last = new_element;
424 if (ex_current_was_cycle_pt)
425 cycle_pt = new_element;
428 current = new_element;
445 "new_element is nullptr");
446 if (new_element->next)
450 if (list->
empty ()) {
451 new_element->next = new_element;
452 new_element->prev = new_element;
453 list->last = new_element;
454 prev = next = new_element;
455 ex_current_was_last =
true;
459 prev->next = new_element;
460 new_element->prev = prev;
463 new_element->next = current;
464 current->prev = new_element;
469 new_element->next = next;
470 next->prev = new_element;
471 if (ex_current_was_last)
472 list->last = new_element;
492 "list_to_add is nullptr");
495 if (!list_to_add->
empty ()) {
496 if (list->
empty ()) {
497 list->last = list_to_add->last;
499 next = list->First ();
500 ex_current_was_last =
true;
505 current->next = list_to_add->First ();
506 current->next->prev = current;
507 if (current == list->last)
508 list->last = list_to_add->last;
509 list_to_add->last->next = next;
510 next->prev = list_to_add->last;
511 next = current->next;
514 prev->next = list_to_add->First ();
515 prev->next->prev = prev;
516 if (ex_current_was_last) {
517 list->last = list_to_add->last;
518 ex_current_was_last =
false;
520 list_to_add->last->next = next;
521 next->prev = list_to_add->last;
525 list_to_add->last =
nullptr;
543 "list_to_add is nullptr");
546 if (!list_to_add->
empty ()) {
547 if (list->
empty ()) {
548 list->last = list_to_add->last;
550 current = list->First ();
551 next = current->next;
552 ex_current_was_last =
false;
555 prev->next = list_to_add->First ();
556 prev->next->prev = prev;
559 list_to_add->last->next = current;
560 current->prev = list_to_add->last;
563 list_to_add->last->next = next;
564 next->prev = list_to_add->last;
565 if (ex_current_was_last)
566 list->last = list_to_add->last;
567 if (ex_current_was_cycle_pt)
568 cycle_pt = prev->next;
570 current = prev->next;
571 next = current->next;
573 list_to_add->last =
nullptr;
600 prev = next = list->last =
nullptr;
605 if (current == list->last) {
607 ex_current_was_last =
true;
609 ex_current_was_last =
false;
613 ex_current_was_cycle_pt = (current == cycle_pt);
614 extracted_link = current;
615 extracted_link->next =
nullptr;
616 extracted_link->prev =
nullptr;
618 return extracted_link;
634 current = list->First ();
636 next = current ? current->next :
nullptr;
653 current = list->last;
654 prev = current ? current->prev :
nullptr;
655 next = current ? current->next :
nullptr;
679 ex_current_was_cycle_pt =
true;
680 started_cycling =
false;
697 return ((list->
empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
698 (prev == list->last) &&
699 !ex_current_was_last));
716 return ((list->
empty ()) || (current == list->last) || ((current ==
nullptr) &&
717 (prev == list->last) &&
718 ex_current_was_last));
734 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
764 const void *,
const void *)) {
770 list->
sort (comparator);
791 "new_element is nullptr");
792 if (new_element->next)
802 list->last = new_element;
805 new_element->next = list->last->next;
806 new_element->prev = list->last;
807 list->last->next->prev = new_element;
808 list->last->next = new_element;
809 list->last = new_element;
821 #define QUOTE_IT(parm) #parm
854 #define ELIST2IZEH_A(CLASSNAME) \
856 extern DLLSYM void CLASSNAME##_zapper( \
859 #define ELIST2IZEH_B(CLASSNAME) \
870 class DLLSYM CLASSNAME##_LIST : public ELIST2 { \
872 CLASSNAME##_LIST() : ELIST2() {} \
876 const CLASSNAME##_LIST &) \
878 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, \
884 ELIST2::internal_clear(&CLASSNAME##_zapper); \
887 ~CLASSNAME##_LIST() \
893 void deep_copy(const CLASSNAME##_LIST *src_list, \
894 CLASSNAME *(*copier)(const CLASSNAME *)); \
897 const CLASSNAME##_LIST &) { \
898 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr); \
901 #define ELIST2IZEH_C(CLASSNAME) \
916 class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR { \
918 CLASSNAME##_IT(CLASSNAME##_LIST *list) : ELIST2_ITERATOR(list) {} \
920 CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \
922 CLASSNAME *data_relative(int8_t offset) { \
923 return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \
926 CLASSNAME *forward() { return (CLASSNAME *)ELIST2_ITERATOR::forward(); } \
928 CLASSNAME *backward() { return (CLASSNAME *)ELIST2_ITERATOR::backward(); } \
930 CLASSNAME *extract() { return (CLASSNAME *)ELIST2_ITERATOR::extract(); } \
932 CLASSNAME *move_to_first() { \
933 return (CLASSNAME *)ELIST2_ITERATOR::move_to_first(); \
936 CLASSNAME *move_to_last() { \
937 return (CLASSNAME *)ELIST2_ITERATOR::move_to_last(); \
943 #define ELIST2IZEH(CLASSNAME) \
945 ELIST2IZEH_A(CLASSNAME) \
947 ELIST2IZEH_B(CLASSNAME) \
949 ELIST2IZEH_C(CLASSNAME)
955 #define ELIST2IZE(CLASSNAME) \
966 DLLSYM void CLASSNAME##_zapper( \
969 delete (CLASSNAME *)link; \
973 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST *src_list, \
974 CLASSNAME *(*copier)(const CLASSNAME *)) { \
975 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST *>(src_list)); \
976 CLASSNAME##_IT to_it(this); \
978 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \
979 to_it.add_after_then_move((*copier)(from_it.data())); \