120 return last ? last->
next :
nullptr;
128 void internal_clear (
137 return last ? (last == last->
next) :
false;
142 last = from_list->
last;
149 void assign_to_sublist(
157 const void *,
const void *));
169 ELIST_LINK *add_sorted_and_find(
int comparator(
const void*,
const void*),
176 return (add_sorted_and_find(comparator, unique, new_link) == new_link);
215 ELIST *list_to_iterate);
217 void add_after_then_move(
220 void add_after_stay_put(
223 void add_before_then_move(
226 void add_before_stay_put(
232 void add_list_before(
238 NO_LIST.
error (
"ELIST_ITERATOR::data", ABORT,
nullptr);
240 NULL_DATA.
error (
"ELIST_ITERATOR::data", ABORT,
nullptr);
256 void mark_cycle_pt();
261 NO_LIST.
error (
"ELIST_ITERATOR::empty", ABORT,
nullptr);
263 return list->
empty ();
286 const void *,
const void *));
298 ELIST *list_to_iterate) {
300 if (!list_to_iterate)
301 BAD_PARAMETER.
error (
"ELIST_ITERATOR::set_to_list", ABORT,
302 "list_to_iterate is nullptr");
305 list = list_to_iterate;
307 current = list->
First ();
308 next = current ? current->
next :
nullptr;
310 started_cycling = FALSE;
311 ex_current_was_last = FALSE;
312 ex_current_was_cycle_pt = FALSE;
323 set_to_list(list_to_iterate);
338 NO_LIST.
error (
"ELIST_ITERATOR::add_after_then_move", ABORT,
nullptr);
340 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_after_then_move", ABORT,
341 "new_element is nullptr");
342 if (new_element->
next)
343 STILL_LINKED.
error (
"ELIST_ITERATOR::add_after_then_move", ABORT,
nullptr);
346 if (list->
empty ()) {
347 new_element->
next = new_element;
348 list->
last = new_element;
349 prev = next = new_element;
352 new_element->
next = next;
355 current->
next = new_element;
357 if (current == list->
last)
358 list->
last = new_element;
361 prev->
next = new_element;
362 if (ex_current_was_last)
363 list->
last = new_element;
364 if (ex_current_was_cycle_pt)
365 cycle_pt = new_element;
368 current = new_element;
383 NO_LIST.
error (
"ELIST_ITERATOR::add_after_stay_put", ABORT,
nullptr);
385 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_after_stay_put", ABORT,
386 "new_element is nullptr");
387 if (new_element->
next)
388 STILL_LINKED.
error (
"ELIST_ITERATOR::add_after_stay_put", ABORT,
nullptr);
391 if (list->
empty ()) {
392 new_element->
next = new_element;
393 list->
last = new_element;
394 prev = next = new_element;
395 ex_current_was_last = FALSE;
399 new_element->
next = next;
402 current->
next = new_element;
405 if (current == list->
last)
406 list->
last = new_element;
409 prev->
next = new_element;
410 if (ex_current_was_last) {
411 list->
last = new_element;
412 ex_current_was_last = FALSE;
431 NO_LIST.
error (
"ELIST_ITERATOR::add_before_then_move", ABORT,
nullptr);
433 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_before_then_move", ABORT,
434 "new_element is nullptr");
435 if (new_element->
next)
436 STILL_LINKED.
error (
"ELIST_ITERATOR::add_before_then_move", ABORT,
nullptr);
439 if (list->
empty ()) {
440 new_element->
next = new_element;
441 list->
last = new_element;
442 prev = next = new_element;
445 prev->
next = new_element;
447 new_element->
next = current;
451 new_element->
next = next;
452 if (ex_current_was_last)
453 list->
last = new_element;
454 if (ex_current_was_cycle_pt)
455 cycle_pt = new_element;
458 current = new_element;
472 NO_LIST.
error (
"ELIST_ITERATOR::add_before_stay_put", ABORT,
nullptr);
474 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_before_stay_put", ABORT,
475 "new_element is nullptr");
476 if (new_element->
next)
477 STILL_LINKED.
error (
"ELIST_ITERATOR::add_before_stay_put", ABORT,
nullptr);
480 if (list->
empty ()) {
481 new_element->
next = new_element;
482 list->
last = new_element;
483 prev = next = new_element;
484 ex_current_was_last = TRUE;
488 prev->next = new_element;
490 new_element->
next = current;
495 new_element->
next = next;
496 if (ex_current_was_last)
497 list->
last = new_element;
514 NO_LIST.
error (
"ELIST_ITERATOR::add_list_after", ABORT,
nullptr);
516 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_list_after", ABORT,
517 "list_to_add is nullptr");
520 if (!list_to_add->
empty ()) {
521 if (list->
empty ()) {
524 next = list->
First ();
525 ex_current_was_last = TRUE;
530 current->next = list_to_add->
First ();
531 if (current == list->
last)
534 next = current->
next;
538 if (ex_current_was_last) {
540 ex_current_was_last = FALSE;
546 list_to_add->
last =
nullptr;
562 NO_LIST.
error (
"ELIST_ITERATOR::add_list_before", ABORT,
nullptr);
564 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_list_before", ABORT,
565 "list_to_add is nullptr");
568 if (!list_to_add->
empty ()) {
569 if (list->
empty ()) {
572 current = list->
First ();
573 next = current->
next;
574 ex_current_was_last = FALSE;
577 prev->next = list_to_add->
First ();
583 if (ex_current_was_last)
585 if (ex_current_was_cycle_pt)
586 cycle_pt = prev->
next;
588 current = prev->
next;
589 next = current->
next;
591 list_to_add->
last =
nullptr;
610 NO_LIST.
error (
"ELIST_ITERATOR::extract", ABORT,
nullptr);
613 NULL_CURRENT.
error (
"ELIST_ITERATOR::extract",
619 prev = next = list->
last =
nullptr;
623 if (current == list->
last) {
625 ex_current_was_last = TRUE;
627 ex_current_was_last = FALSE;
631 ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE;
632 extracted_link = current;
633 extracted_link->
next =
nullptr;
635 return extracted_link;
649 NO_LIST.
error (
"ELIST_ITERATOR::move_to_first", ABORT,
nullptr);
652 current = list->
First ();
654 next = current ? current->
next :
nullptr;
673 NO_LIST.
error (
"ELIST_ITERATOR::mark_cycle_pt", ABORT,
nullptr);
679 ex_current_was_cycle_pt = TRUE;
680 started_cycling = FALSE;
694 NO_LIST.
error (
"ELIST_ITERATOR::at_first", ABORT,
nullptr);
698 return ((list->
empty ()) || (current == list->
First ()) || ((current ==
nullptr) &&
699 (prev == list->
last) &&
700 !ex_current_was_last));
714 NO_LIST.
error (
"ELIST_ITERATOR::at_last", ABORT,
nullptr);
718 return ((list->
empty ()) || (current == list->
last) || ((current ==
nullptr) &&
719 (prev == list->
last) &&
720 ex_current_was_last));
734 NO_LIST.
error (
"ELIST_ITERATOR::cycled_list", ABORT,
nullptr);
737 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
752 NO_LIST.
error (
"ELIST_ITERATOR::length", ABORT,
nullptr);
769 const void *,
const void *)) {
772 NO_LIST.
error (
"ELIST_ITERATOR::sort", ABORT,
nullptr);
775 list->
sort (comparator);
794 NO_LIST.
error (
"ELIST_ITERATOR::add_to_end", ABORT,
nullptr);
796 BAD_PARAMETER.
error (
"ELIST_ITERATOR::add_to_end", ABORT,
797 "new_element is nullptr");
798 if (new_element->
next)
799 STILL_LINKED.
error (
"ELIST_ITERATOR::add_to_end", ABORT,
nullptr);
802 if (this->at_last ()) {
803 this->add_after_stay_put (new_element);
806 if (this->at_first ()) {
807 this->add_before_stay_put (new_element);
808 list->
last = new_element;
813 list->
last = new_element;
829 #define QUOTE_IT(parm) #parm 861 #define ELISTIZEH_A(CLASSNAME) \ 863 extern DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link); 865 #define ELISTIZEH_B(CLASSNAME) \ 874 class DLLSYM CLASSNAME##_LIST : public ELIST { \ 876 CLASSNAME##_LIST():ELIST() {} \ 879 ELIST::internal_clear(&CLASSNAME##_zapper); \ 882 ~CLASSNAME##_LIST() { \ 887 void deep_copy(const CLASSNAME##_LIST* src_list, \ 888 CLASSNAME* (*copier)(const CLASSNAME*)); \ 892 CLASSNAME##_LIST(const CLASSNAME##_LIST&) { \ 893 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr);\ 895 void operator=(const CLASSNAME##_LIST&) { \ 896 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, nullptr); \ 899 #define ELISTIZEH_C(CLASSNAME) \ 915 class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \ 917 CLASSNAME##_IT():ELIST_ITERATOR(){} \ 921 CLASSNAME##_IT(CLASSNAME##_LIST* list) : ELIST_ITERATOR(list) {} \ 923 CLASSNAME* data() { \ 924 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \ 927 CLASSNAME* data_relative(int8_t offset) { \ 928 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\ 931 CLASSNAME* forward() { \ 932 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::forward()); \ 935 CLASSNAME* extract() { \ 936 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::extract()); \ 939 CLASSNAME* move_to_first() { \ 940 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_first()); \ 943 CLASSNAME* move_to_last() { \ 944 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_last()); \ 948 #define ELISTIZEH(CLASSNAME) \ 950 ELISTIZEH_A(CLASSNAME) \ 952 ELISTIZEH_B(CLASSNAME) \ 954 ELISTIZEH_C(CLASSNAME) 961 #define ELISTIZE(CLASSNAME) \ 972 DLLSYM void CLASSNAME##_zapper(ELIST_LINK *link) { \ 973 delete reinterpret_cast<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())); \ ELIST_LINK * last
Definition: elst.h:117
int32_t length()
Definition: elst.h:749
ELIST * list
Definition: elst.h:191
ELIST_LINK()
Definition: elst.h:92
bool ex_current_was_last
Definition: elst.h:195
ELIST_LINK * current
Definition: elst.h:193
void set_to_list(ELIST *list_to_iterate)
Definition: elst.h:297
void add_list_before(ELIST *list_to_add)
Definition: elst.h:559
bool add_sorted(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
Definition: elst.h:174
ELIST_LINK * prev
Definition: elst.h:192
ELIST_LINK * extract()
Definition: elst.h:605
void add_before_stay_put(ELIST_LINK *new_link)
Definition: elst.h:468
void add_list_after(ELIST *list_to_add)
Definition: elst.h:511
bool at_last()
Definition: elst.h:711
void operator=(const ELIST_LINK &)
Definition: elst.h:101
ELIST_LINK(const ELIST_LINK &)
Definition: elst.h:97
ELIST()
Definition: elst.h:124
ELIST_LINK * next
Definition: elst.h:89
void add_before_then_move(ELIST_LINK *new_link)
Definition: elst.h:427
bool started_cycling
Definition: elst.h:201
ELIST_LINK * cycle_pt
Definition: elst.h:199
void sort(int comparator(const void *, const void *))
Definition: elst.h:767
bool empty() const
Definition: elst.h:132
void shallow_copy(ELIST *from_list)
Definition: elst.h:140
bool cycled_list()
Definition: elst.h:731
void add_after_then_move(ELIST_LINK *new_link)
Definition: elst.h:334
ELIST_LINK * next
Definition: elst.h:194
void add_after_stay_put(ELIST_LINK *new_link)
Definition: elst.h:379
void add_to_end(ELIST_LINK *new_link)
Definition: elst.h:790
int32_t length() const
Definition: elst.cpp:90
bool ex_current_was_cycle_pt
Definition: elst.h:197
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)
Definition: elst.cpp:72
ELIST_LINK * move_to_first()
Definition: elst.h:646
bool current_extracted()
Definition: elst.h:266
bool at_first()
Definition: elst.h:691
ELIST_ITERATOR()
Definition: elst.h:208
bool empty()
Definition: elst.h:258
void mark_cycle_pt()
Definition: elst.h:670
bool singleton() const
Definition: elst.h:136
ELIST_LINK * data()
Definition: elst.h:235
ELIST_LINK * First()
Definition: elst.h:119
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37
void sort(int comparator(const void *, const void *))
Definition: elst.cpp:108