118 return last ? last->next :
nullptr;
126 void internal_clear (
135 return last ? (last == last->next) :
false;
140 last = from_list->last;
147 void assign_to_sublist(
155 const void *,
const void *));
167 ELIST_LINK *add_sorted_and_find(
int comparator(
const void*,
const void*),
174 return (add_sorted_and_find(comparator, unique, new_link) == new_link);
193 bool ex_current_was_last;
195 bool ex_current_was_cycle_pt;
199 bool started_cycling;
213 ELIST *list_to_iterate);
215 void add_after_then_move(
218 void add_after_stay_put(
221 void add_before_then_move(
224 void add_before_stay_put(
230 void add_list_before(
254 void mark_cycle_pt();
261 return list->
empty ();
284 const void *,
const void *));
296 ELIST *list_to_iterate) {
298 if (!list_to_iterate)
300 "list_to_iterate is nullptr");
303 list = list_to_iterate;
305 current = list->First ();
306 next = current ? current->next :
nullptr;
308 started_cycling =
false;
309 ex_current_was_last =
false;
310 ex_current_was_cycle_pt =
false;
321 set_to_list(list_to_iterate);
339 "new_element is nullptr");
340 if (new_element->next)
344 if (list->
empty ()) {
345 new_element->next = new_element;
346 list->last = new_element;
347 prev = next = new_element;
350 new_element->next = next;
353 current->next = new_element;
355 if (current == list->last)
356 list->last = new_element;
359 prev->next = new_element;
360 if (ex_current_was_last)
361 list->last = new_element;
362 if (ex_current_was_cycle_pt)
363 cycle_pt = new_element;
366 current = new_element;
384 "new_element is nullptr");
385 if (new_element->next)
389 if (list->
empty ()) {
390 new_element->next = new_element;
391 list->last = new_element;
392 prev = next = new_element;
393 ex_current_was_last =
false;
397 new_element->next = next;
400 current->next = new_element;
403 if (current == list->last)
404 list->last = new_element;
407 prev->next = new_element;
408 if (ex_current_was_last) {
409 list->last = new_element;
410 ex_current_was_last =
false;
432 "new_element is nullptr");
433 if (new_element->next)
437 if (list->
empty ()) {
438 new_element->next = new_element;
439 list->last = new_element;
440 prev = next = new_element;
443 prev->next = new_element;
445 new_element->next = current;
449 new_element->next = next;
450 if (ex_current_was_last)
451 list->last = new_element;
452 if (ex_current_was_cycle_pt)
453 cycle_pt = new_element;
456 current = new_element;
473 "new_element is nullptr");
474 if (new_element->next)
478 if (list->
empty ()) {
479 new_element->next = new_element;
480 list->last = new_element;
481 prev = next = new_element;
482 ex_current_was_last =
true;
486 prev->next = new_element;
488 new_element->next = current;
493 new_element->next = next;
494 if (ex_current_was_last)
495 list->last = new_element;
515 "list_to_add is nullptr");
518 if (!list_to_add->
empty ()) {
519 if (list->
empty ()) {
520 list->last = list_to_add->last;
522 next = list->First ();
523 ex_current_was_last =
true;
528 current->next = list_to_add->First ();
529 if (current == list->last)
530 list->last = list_to_add->last;
531 list_to_add->last->next = next;
532 next = current->next;
535 prev->next = list_to_add->First ();
536 if (ex_current_was_last) {
537 list->last = list_to_add->last;
538 ex_current_was_last =
false;
540 list_to_add->last->next = next;
544 list_to_add->last =
nullptr;
563 "list_to_add is nullptr");
566 if (!list_to_add->
empty ()) {
567 if (list->
empty ()) {
568 list->last = list_to_add->last;
570 current = list->First ();
571 next = current->next;
572 ex_current_was_last =
false;
575 prev->next = list_to_add->First ();
577 list_to_add->last->next = current;
580 list_to_add->last->next = next;
581 if (ex_current_was_last)
582 list->last = list_to_add->last;
583 if (ex_current_was_cycle_pt)
584 cycle_pt = prev->next;
586 current = prev->next;
587 next = current->next;
589 list_to_add->last =
nullptr;
617 prev = next = list->last =
nullptr;
621 ex_current_was_last = (current == list->last);
622 if (ex_current_was_last) list->last = prev;
625 ex_current_was_cycle_pt = (current == cycle_pt);
626 extracted_link = current;
627 extracted_link->next =
nullptr;
629 return extracted_link;
646 current = list->First ();
648 next = current ? current->next :
nullptr;
673 ex_current_was_cycle_pt =
true;
674 started_cycling =
false;
692 return ((list->
empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
693 (prev == list->last) &&
694 !ex_current_was_last));
712 return ((list->
empty ()) || (current == list->last) || ((current ==
nullptr) &&
713 (prev == list->last) &&
714 ex_current_was_last));
731 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
763 const void *,
const void *)) {
769 list->
sort (comparator);
791 "new_element is nullptr");
792 if (new_element->next)
796 if (this->at_last ()) {
797 this->add_after_stay_put (new_element);
800 if (this->at_first ()) {
801 this->add_before_stay_put (new_element);
802 list->last = new_element;
805 new_element->next = list->last->next;
806 list->last->next = new_element;
807 list->last = new_element;
823 #define QUOTE_IT(parm) #parm 855 #define ELISTIZEH_A(CLASSNAME) \ 857 extern DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link); 859 #define ELISTIZEH_B(CLASSNAME) \ 868 class DLLSYM CLASSNAME##_LIST : public ELIST { \ 870 CLASSNAME##_LIST():ELIST() {} \ 873 ELIST::internal_clear(&CLASSNAME##_zapper); \ 876 ~CLASSNAME##_LIST() { \ 881 void deep_copy(const CLASSNAME##_LIST* src_list, \ 882 CLASSNAME* (*copier)(const CLASSNAME*)); \ 886 CLASSNAME##_LIST(const CLASSNAME##_LIST&) { \ 887 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr);\ 889 void operator=(const CLASSNAME##_LIST&) { \ 890 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr); \ 893 #define ELISTIZEH_C(CLASSNAME) \ 909 class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \ 911 CLASSNAME##_IT():ELIST_ITERATOR(){} \ 915 CLASSNAME##_IT(CLASSNAME##_LIST* list) : ELIST_ITERATOR(list) {} \ 917 CLASSNAME* data() { \ 918 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \ 921 CLASSNAME* data_relative(int8_t offset) { \ 922 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\ 925 CLASSNAME* forward() { \ 926 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::forward()); \ 929 CLASSNAME* extract() { \ 930 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::extract()); \ 933 CLASSNAME* move_to_first() { \ 934 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_first()); \ 937 CLASSNAME* move_to_last() { \ 938 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_last()); \ 942 #define ELISTIZEH(CLASSNAME) \ 944 ELISTIZEH_A(CLASSNAME) \ 946 ELISTIZEH_B(CLASSNAME) \ 948 ELISTIZEH_C(CLASSNAME) 955 #define ELISTIZE(CLASSNAME) \ 966 DLLSYM void CLASSNAME##_zapper(ELIST_LINK *link) { \ 967 delete reinterpret_cast<CLASSNAME *>(link); \ 971 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST *src_list, \ 972 CLASSNAME *(*copier)(const CLASSNAME *)) { \ 973 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST *>(src_list)); \ 974 CLASSNAME##_IT to_it(this); \ 976 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \ 977 to_it.add_after_then_move((*copier)(from_it.data())); \
ELIST_LINK * move_to_first()
void add_after_then_move(ELIST_LINK *new_link)
void operator=(const ELIST_LINK &)
void add_after_stay_put(ELIST_LINK *new_link)
void sort(int comparator(
const void *, const void *))
ELIST_LINK(const ELIST_LINK &)
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void add_list_before(ELIST *list_to_add)
constexpr ERRCODE BAD_PARAMETER("List parameter error")
void add_before_then_move(ELIST_LINK *new_link)
void shallow_copy(ELIST *from_list)
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
void add_list_after(ELIST *list_to_add)
bool add_sorted(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
void add_before_stay_put(ELIST_LINK *new_link)
void add_to_end(ELIST_LINK *new_link)
void sort(int comparator(
const void *, const void *))
void set_to_list(ELIST *list_to_iterate)
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)