120 return last ? last->next :
NULL;
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);
195 bool ex_current_was_last;
197 bool ex_current_was_cycle_pt;
201 bool started_cycling;
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(
256 void mark_cycle_pt();
263 return list->
empty ();
286 const void *,
const void *));
298 ELIST *list_to_iterate) {
302 if (!list_to_iterate)
304 "list_to_iterate is NULL");
307 list = list_to_iterate;
309 current = list->First ();
310 next = current ? current->next :
NULL;
312 started_cycling =
FALSE;
313 ex_current_was_last =
FALSE;
314 ex_current_was_cycle_pt =
FALSE;
345 "new_element is NULL");
346 if (new_element->next)
350 if (list->
empty ()) {
351 new_element->next = new_element;
352 list->last = new_element;
353 prev = next = new_element;
356 new_element->next = next;
359 current->next = new_element;
361 if (current == list->last)
362 list->last = new_element;
365 prev->next = new_element;
366 if (ex_current_was_last)
367 list->last = new_element;
368 if (ex_current_was_cycle_pt)
369 cycle_pt = new_element;
372 current = new_element;
392 "new_element is NULL");
393 if (new_element->next)
397 if (list->
empty ()) {
398 new_element->next = new_element;
399 list->last = new_element;
400 prev = next = new_element;
401 ex_current_was_last =
FALSE;
405 new_element->next = next;
408 current->next = new_element;
411 if (current == list->last)
412 list->last = new_element;
415 prev->next = new_element;
416 if (ex_current_was_last) {
417 list->last = new_element;
418 ex_current_was_last =
FALSE;
442 "new_element is NULL");
443 if (new_element->next)
447 if (list->
empty ()) {
448 new_element->next = new_element;
449 list->last = new_element;
450 prev = next = new_element;
453 prev->next = new_element;
455 new_element->next = current;
459 new_element->next = next;
460 if (ex_current_was_last)
461 list->last = new_element;
462 if (ex_current_was_cycle_pt)
463 cycle_pt = new_element;
466 current = new_element;
486 "new_element is NULL");
487 if (new_element->next)
491 if (list->
empty ()) {
492 new_element->next = new_element;
493 list->last = new_element;
494 prev = next = new_element;
495 ex_current_was_last =
TRUE;
499 prev->next = new_element;
501 new_element->next = current;
506 new_element->next = next;
507 if (ex_current_was_last)
508 list->last = new_element;
530 "list_to_add is NULL");
533 if (!list_to_add->
empty ()) {
534 if (list->
empty ()) {
535 list->last = list_to_add->last;
537 next = list->First ();
538 ex_current_was_last =
TRUE;
543 current->next = list_to_add->First ();
544 if (current == list->last)
545 list->last = list_to_add->last;
546 list_to_add->last->next = next;
547 next = current->next;
550 prev->next = list_to_add->First ();
551 if (ex_current_was_last) {
552 list->last = list_to_add->last;
553 ex_current_was_last =
FALSE;
555 list_to_add->last->next = next;
559 list_to_add->last =
NULL;
580 "list_to_add is NULL");
583 if (!list_to_add->
empty ()) {
584 if (list->
empty ()) {
585 list->last = list_to_add->last;
587 current = list->First ();
588 next = current->next;
589 ex_current_was_last =
FALSE;
592 prev->next = list_to_add->First ();
594 list_to_add->last->next = current;
597 list_to_add->last->next = next;
598 if (ex_current_was_last)
599 list->last = list_to_add->last;
600 if (ex_current_was_cycle_pt)
601 cycle_pt = prev->next;
603 current = prev->next;
604 next = current->next;
606 list_to_add->last =
NULL;
636 prev = next = list->last =
NULL;
640 if (current == list->last) {
642 ex_current_was_last =
TRUE;
644 ex_current_was_last =
FALSE;
648 ex_current_was_cycle_pt = (current == cycle_pt) ?
TRUE :
FALSE;
649 extracted_link = current;
650 extracted_link->next =
NULL;
652 return extracted_link;
671 current = list->First ();
673 next = current ? current->next :
NULL;
700 ex_current_was_cycle_pt =
TRUE;
701 started_cycling =
FALSE;
721 return ((list->
empty ()) || (current == list->First ()) || ((current ==
NULL) &&
722 (prev == list->last) &&
723 !ex_current_was_last));
743 return ((list->
empty ()) || (current == list->last) || ((current ==
NULL) &&
744 (prev == list->last) &&
745 ex_current_was_last));
764 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
798 const void *,
const void *)) {
806 list->
sort (comparator);
830 "new_element is NULL");
831 if (new_element->next)
841 list->last = new_element;
844 new_element->next = list->last->next;
845 list->last->next = new_element;
846 list->last = new_element;
862 #define QUOTE_IT( parm ) #parm
894 #define ELISTIZEH_A(CLASSNAME) \
896 extern DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link);
898 #define ELISTIZEH_B(CLASSNAME) \
907 class DLLSYM CLASSNAME##_LIST : public ELIST { \
909 CLASSNAME##_LIST():ELIST() {} \
912 ELIST::internal_clear(&CLASSNAME##_zapper); \
915 ~CLASSNAME##_LIST() { \
920 void deep_copy(const CLASSNAME##_LIST* src_list, \
921 CLASSNAME* (*copier)(const CLASSNAME*)); \
925 CLASSNAME##_LIST(const CLASSNAME##_LIST&) { \
926 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, NULL);\
928 void operator=(const CLASSNAME##_LIST&) { \
929 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, NULL ); \
932 #define ELISTIZEH_C( CLASSNAME ) \
948 class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \
950 CLASSNAME##_IT():ELIST_ITERATOR(){} \
954 CLASSNAME##_IT(CLASSNAME##_LIST* list) : ELIST_ITERATOR(list) {} \
956 CLASSNAME* data() { \
957 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \
960 CLASSNAME* data_relative(inT8 offset) { \
961 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\
964 CLASSNAME* forward() { \
965 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::forward()); \
968 CLASSNAME* extract() { \
969 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::extract()); \
972 CLASSNAME* move_to_first() { \
973 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_first()); \
976 CLASSNAME* move_to_last() { \
977 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_last()); \
981 #define ELISTIZEH( CLASSNAME ) \
983 ELISTIZEH_A( CLASSNAME ) \
985 ELISTIZEH_B( CLASSNAME ) \
987 ELISTIZEH_C( CLASSNAME )
994 #define ELISTIZE(CLASSNAME) \
1005 DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link) { \
1006 delete reinterpret_cast<CLASSNAME*>(link); \
1010 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST* src_list, \
1011 CLASSNAME* (*copier)(const CLASSNAME*)) { \
1013 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST*>(src_list)); \
1014 CLASSNAME##_IT to_it(this); \
1016 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \
1017 to_it.add_after_then_move((*copier)(from_it.data())); \
ELIST_LINK * move_to_first()
void set_to_list(ELIST *list_to_iterate)
void add_to_end(ELIST_LINK *new_link)
void sort(int comparator(const void *, const void *))
const ERRCODE BAD_PARAMETER
void add_list_before(ELIST *list_to_add)
void add_after_stay_put(ELIST_LINK *new_link)
void add_after_then_move(ELIST_LINK *new_link)
void add_before_then_move(ELIST_LINK *new_link)
const ERRCODE NULL_CURRENT
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void sort(int comparator(const void *, const void *))
void add_list_after(ELIST *list_to_add)
void shallow_copy(ELIST *from_list)
bool add_sorted(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
const ERRCODE STILL_LINKED
const ERRCODE NULL_OBJECT
ELIST_LINK(const ELIST_LINK &)
void assign_to_sublist(ELIST_ITERATOR *start_it, ELIST_ITERATOR *end_it)
void add_before_stay_put(ELIST_LINK *new_link)