66 prev = next =
nullptr;
71 prev = next =
nullptr;
76 prev = next =
nullptr;
93 return last ? last->next :
nullptr;
101 void internal_clear (
110 return last ? (last == last->next) :
false;
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*),
157 bool ex_current_was_last;
159 bool ex_current_was_cycle_pt;
163 bool started_cycling;
176 void add_after_then_move(
179 void add_after_stay_put(
182 void add_before_then_move(
185 void add_before_stay_put(
191 void add_list_before(
218 void mark_cycle_pt();
225 return list->
empty ();
248 const void *,
const void *));
263 ELIST2 *list_to_iterate) {
265 if (!list_to_iterate)
267 "list_to_iterate is nullptr");
270 list = list_to_iterate;
272 current = list->First ();
273 next = current ? current->next :
nullptr;
275 started_cycling =
false;
276 ex_current_was_last =
false;
277 ex_current_was_cycle_pt =
false;
287 set_to_list(list_to_iterate);
304 "new_element is nullptr");
305 if (new_element->next)
309 if (list->empty ()) {
310 new_element->next = new_element;
311 new_element->prev = new_element;
312 list->last = new_element;
313 prev = next = new_element;
316 new_element->next = next;
317 next->prev = new_element;
320 new_element->prev = current;
321 current->next = new_element;
323 if (current == list->last)
324 list->last = new_element;
327 new_element->prev = prev;
328 prev->next = new_element;
329 if (ex_current_was_last)
330 list->last = new_element;
331 if (ex_current_was_cycle_pt)
332 cycle_pt = new_element;
335 current = new_element;
352 "new_element is nullptr");
353 if (new_element->next)
357 if (list->empty ()) {
358 new_element->next = new_element;
359 new_element->prev = new_element;
360 list->last = new_element;
361 prev = next = new_element;
362 ex_current_was_last =
false;
366 new_element->next = next;
367 next->prev = new_element;
370 new_element->prev = current;
371 current->next = new_element;
374 if (current == list->last)
375 list->last = new_element;
378 new_element->prev = prev;
379 prev->next = new_element;
380 if (ex_current_was_last) {
381 list->last = new_element;
382 ex_current_was_last =
false;
403 "new_element is nullptr");
404 if (new_element->next)
408 if (list->empty ()) {
409 new_element->next = new_element;
410 new_element->prev = new_element;
411 list->last = new_element;
412 prev = next = new_element;
415 prev->next = new_element;
416 new_element->prev = prev;
419 new_element->next = current;
420 current->prev = new_element;
424 new_element->next = next;
425 next->prev = new_element;
426 if (ex_current_was_last)
427 list->last = new_element;
428 if (ex_current_was_cycle_pt)
429 cycle_pt = new_element;
432 current = new_element;
449 "new_element is nullptr");
450 if (new_element->next)
454 if (list->empty ()) {
455 new_element->next = new_element;
456 new_element->prev = new_element;
457 list->last = new_element;
458 prev = next = new_element;
459 ex_current_was_last =
true;
463 prev->next = new_element;
464 new_element->prev = prev;
467 new_element->next = current;
468 current->prev = new_element;
473 new_element->next = next;
474 next->prev = new_element;
475 if (ex_current_was_last)
476 list->last = new_element;
496 "list_to_add is nullptr");
499 if (!list_to_add->
empty ()) {
500 if (list->empty ()) {
501 list->last = list_to_add->last;
503 next = list->First ();
504 ex_current_was_last =
true;
509 current->next = list_to_add->First ();
510 current->next->prev = current;
511 if (current == list->last)
512 list->last = list_to_add->last;
513 list_to_add->last->next = next;
514 next->prev = list_to_add->last;
515 next = current->next;
518 prev->next = list_to_add->First ();
519 prev->next->prev = prev;
520 if (ex_current_was_last) {
521 list->last = list_to_add->last;
522 ex_current_was_last =
false;
524 list_to_add->last->next = next;
525 next->prev = list_to_add->last;
529 list_to_add->last =
nullptr;
547 "list_to_add is nullptr");
550 if (!list_to_add->
empty ()) {
551 if (list->empty ()) {
552 list->last = list_to_add->last;
554 current = list->First ();
555 next = current->next;
556 ex_current_was_last =
false;
559 prev->next = list_to_add->First ();
560 prev->next->prev = prev;
563 list_to_add->last->next = current;
564 current->prev = list_to_add->last;
567 list_to_add->last->next = next;
568 next->prev = list_to_add->last;
569 if (ex_current_was_last)
570 list->last = list_to_add->last;
571 if (ex_current_was_cycle_pt)
572 cycle_pt = prev->next;
574 current = prev->next;
575 next = current->next;
577 list_to_add->last =
nullptr;
602 if (list->singleton()) {
604 prev = next = list->last =
nullptr;
609 if (current == list->last) {
611 ex_current_was_last =
true;
613 ex_current_was_last =
false;
617 ex_current_was_cycle_pt = (current == cycle_pt);
618 extracted_link = current;
619 extracted_link->next =
nullptr;
620 extracted_link->prev =
nullptr;
622 return extracted_link;
638 current = list->First ();
640 next = current ? current->next :
nullptr;
657 current = list->last;
658 prev = current ? current->prev :
nullptr;
659 next = current ? current->next :
nullptr;
683 ex_current_was_cycle_pt =
true;
684 started_cycling =
false;
701 return ((list->empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
702 (prev == list->last) &&
703 !ex_current_was_last));
720 return ((list->empty ()) || (current == list->last) || ((current ==
nullptr) &&
721 (prev == list->last) &&
722 ex_current_was_last));
738 return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
755 return list->length ();
768 const void *,
const void *)) {
774 list->sort (comparator);
795 "new_element is nullptr");
796 if (new_element->next)
800 if (this->at_last ()) {
801 this->add_after_stay_put (new_element);
804 if (this->at_first ()) {
805 this->add_before_stay_put (new_element);
806 list->last = new_element;
809 new_element->next = list->last->next;
810 new_element->prev = list->last;
811 list->last->next->prev = new_element;
812 list->last->next = new_element;
813 list->last = new_element;
825 #define QUOTE_IT(parm) #parm 858 #define ELIST2IZEH_A(CLASSNAME) \ 860 extern DLLSYM void CLASSNAME##_zapper( \ 863 #define ELIST2IZEH_B(CLASSNAME) \ 874 class DLLSYM CLASSNAME##_LIST : public ELIST2 { \ 876 CLASSNAME##_LIST() : ELIST2() {} \ 880 const CLASSNAME##_LIST &) \ 882 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, \ 888 ELIST2::internal_clear(&CLASSNAME##_zapper); \ 891 ~CLASSNAME##_LIST() \ 897 void deep_copy(const CLASSNAME##_LIST *src_list, \ 898 CLASSNAME *(*copier)(const CLASSNAME *)); \ 901 const CLASSNAME##_LIST &) { \ 902 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr); \ 905 #define ELIST2IZEH_C(CLASSNAME) \ 920 class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR { \ 922 CLASSNAME##_IT(CLASSNAME##_LIST *list) : ELIST2_ITERATOR(list) {} \ 924 CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \ 926 CLASSNAME *data_relative(int8_t offset) { \ 927 return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \ 930 CLASSNAME *forward() { return (CLASSNAME *)ELIST2_ITERATOR::forward(); } \ 932 CLASSNAME *backward() { return (CLASSNAME *)ELIST2_ITERATOR::backward(); } \ 934 CLASSNAME *extract() { return (CLASSNAME *)ELIST2_ITERATOR::extract(); } \ 936 CLASSNAME *move_to_first() { \ 937 return (CLASSNAME *)ELIST2_ITERATOR::move_to_first(); \ 940 CLASSNAME *move_to_last() { \ 941 return (CLASSNAME *)ELIST2_ITERATOR::move_to_last(); \ 947 #define ELIST2IZEH(CLASSNAME) \ 949 ELIST2IZEH_A(CLASSNAME) \ 951 ELIST2IZEH_B(CLASSNAME) \ 953 ELIST2IZEH_C(CLASSNAME) 959 #define ELIST2IZE(CLASSNAME) \ 970 DLLSYM void CLASSNAME##_zapper( \ 973 delete (CLASSNAME *)link; \ 977 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST *src_list, \ 978 CLASSNAME *(*copier)(const CLASSNAME *)) { \ 979 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST *>(src_list)); \ 980 CLASSNAME##_IT to_it(this); \ 982 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \ 983 to_it.add_after_then_move((*copier)(from_it.data())); \
void add_before_then_move(ELIST2_LINK *new_link)
ELIST2_ITERATOR(ELIST2 *list_to_iterate)
void add_after_then_move(ELIST2_LINK *new_link)
void add_after_stay_put(ELIST2_LINK *new_link)
void add_list_before(ELIST2 *list_to_add)
ELIST2_LINK * move_to_first()
void add_to_end(ELIST2_LINK *new_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_before_stay_put(ELIST2_LINK *new_link)
ELIST2_LINK * move_to_last()
void shallow_copy(ELIST2 *from_list)
constexpr ERRCODE BAD_PARAMETER("List parameter error")
ELIST2_LINK(const ELIST2_LINK &)
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(ELIST2 *list_to_add)
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
void operator=(const ELIST2_LINK &)
void sort(int comparator(
const void *, const void *))
void set_to_list(ELIST2 *list_to_iterate)