128 void internal_clear (
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) {
300 if (!list_to_iterate)
302 "list_to_iterate is NULL");
305 list = list_to_iterate;
307 current = list->First ();
308 next = current ? current->next : NULL;
310 started_cycling =
FALSE;
311 ex_current_was_last =
FALSE;
312 ex_current_was_cycle_pt =
FALSE;
341 "new_element is NULL");
342 if (new_element->next)
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;
386 "new_element is NULL");
387 if (new_element->next)
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;
434 "new_element is NULL");
435 if (new_element->next)
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;
476 "new_element is NULL");
477 if (new_element->next)
481 if (list->
empty ()) {
482 new_element->next = new_element;
483 list->last = new_element;
484 prev = next = new_element;
485 ex_current_was_last =
TRUE;
489 prev->next = new_element;
491 new_element->next = current;
496 new_element->next = next;
497 if (ex_current_was_last)
498 list->last = new_element;
518 "list_to_add is NULL");
521 if (!list_to_add->
empty ()) {
522 if (list->
empty ()) {
523 list->last = list_to_add->last;
525 next = list->First ();
526 ex_current_was_last =
TRUE;
531 current->next = list_to_add->First ();
532 if (current == list->last)
533 list->last = list_to_add->last;
534 list_to_add->last->next = next;
535 next = current->next;
538 prev->next = list_to_add->First ();
539 if (ex_current_was_last) {
540 list->last = list_to_add->last;
541 ex_current_was_last =
FALSE;
543 list_to_add->last->next = next;
547 list_to_add->last = NULL;
566 "list_to_add is NULL");
569 if (!list_to_add->
empty ()) {
570 if (list->
empty ()) {
571 list->last = list_to_add->last;
573 current = list->First ();
574 next = current->next;
575 ex_current_was_last =
FALSE;
578 prev->next = list_to_add->First ();
580 list_to_add->last->next = current;
583 list_to_add->last->next = next;
584 if (ex_current_was_last)
585 list->last = list_to_add->last;
586 if (ex_current_was_cycle_pt)
587 cycle_pt = prev->next;
589 current = prev->next;
590 next = current->next;
592 list_to_add->last = NULL;
620 prev = next = list->last = NULL;
624 if (current == list->last) {
626 ex_current_was_last =
TRUE;
628 ex_current_was_last =
FALSE;
632 ex_current_was_cycle_pt = (current == cycle_pt) ?
TRUE :
FALSE;
633 extracted_link = current;
634 extracted_link->next = NULL;
636 return extracted_link;
653 current = list->First ();
655 next = current ? current->next : NULL;
680 ex_current_was_cycle_pt =
TRUE;
681 started_cycling =
FALSE;
699 return ((list->
empty ()) || (current == list->First ()) || ((current == NULL) &&
700 (prev == list->last) &&
701 !ex_current_was_last));
719 return ((list->
empty ()) || (current == list->last) || ((current == NULL) &&
720 (prev == list->last) &&
721 ex_current_was_last));
738 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
770 const void *,
const void *)) {
776 list->
sort (comparator);
798 "new_element is NULL");
799 if (new_element->next)
809 list->last = new_element;
812 new_element->next = list->last->next;
813 list->last->next = new_element;
814 list->last = new_element;
830 #define QUOTE_IT( parm ) #parm
862 #define ELISTIZEH_A(CLASSNAME) \
864 extern DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link);
866 #define ELISTIZEH_B(CLASSNAME) \
875 class DLLSYM CLASSNAME##_LIST : public ELIST { \
877 CLASSNAME##_LIST():ELIST() {} \
880 ELIST::internal_clear(&CLASSNAME##_zapper); \
883 ~CLASSNAME##_LIST() { \
888 void deep_copy(const CLASSNAME##_LIST* src_list, \
889 CLASSNAME* (*copier)(const CLASSNAME*)); \
893 CLASSNAME##_LIST(const CLASSNAME##_LIST&) { \
894 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, NULL);\
896 void operator=(const CLASSNAME##_LIST&) { \
897 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, NULL ); \
900 #define ELISTIZEH_C( CLASSNAME ) \
916 class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \
918 CLASSNAME##_IT():ELIST_ITERATOR(){} \
922 CLASSNAME##_IT(CLASSNAME##_LIST* list) : ELIST_ITERATOR(list) {} \
924 CLASSNAME* data() { \
925 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \
928 CLASSNAME* data_relative(inT8 offset) { \
929 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\
932 CLASSNAME* forward() { \
933 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::forward()); \
936 CLASSNAME* extract() { \
937 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::extract()); \
940 CLASSNAME* move_to_first() { \
941 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_first()); \
944 CLASSNAME* move_to_last() { \
945 return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::move_to_last()); \
949 #define ELISTIZEH( CLASSNAME ) \
951 ELISTIZEH_A( CLASSNAME ) \
953 ELISTIZEH_B( CLASSNAME ) \
955 ELISTIZEH_C( CLASSNAME )
962 #define ELISTIZE(CLASSNAME) \
973 DLLSYM void CLASSNAME##_zapper(ELIST_LINK* link) { \
974 delete reinterpret_cast<CLASSNAME*>(link); \
978 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST* src_list, \
979 CLASSNAME* (*copier)(const CLASSNAME*)) { \
981 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST*>(src_list)); \
982 CLASSNAME##_IT to_it(this); \
984 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \
985 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
const ERRCODE STILL_LINKED
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)
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)
const ERRCODE NULL_CURRENT
bool add_sorted(int comparator(const void *, const void *), bool unique, ELIST_LINK *new_link)
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)