95 return last ? last->next :
NULL;
103 void internal_clear (
112 return last ? (last == last->next) :
false;
117 last = from_list->last;
124 void assign_to_sublist(
132 const void *,
const void *));
139 void add_sorted(
int comparator(
const void*,
const void*),
158 BOOL8 ex_current_was_last;
160 BOOL8 ex_current_was_cycle_pt;
164 BOOL8 started_cycling;
181 void add_after_then_move(
184 void add_after_stay_put(
187 void add_before_then_move(
190 void add_before_stay_put(
196 void add_list_before(
223 void mark_cycle_pt();
230 return list->
empty ();
253 const void *,
const void *));
265 ELIST2 *list_to_iterate) {
269 if (!list_to_iterate)
271 "list_to_iterate is NULL");
274 list = list_to_iterate;
276 current = list->First ();
277 next = current ? current->next :
NULL;
279 started_cycling =
FALSE;
280 ex_current_was_last =
FALSE;
281 ex_current_was_cycle_pt =
FALSE;
292 set_to_list(list_to_iterate);
312 "new_element is NULL");
313 if (new_element->next)
317 if (list->empty ()) {
318 new_element->next = new_element;
319 new_element->prev = new_element;
320 list->last = new_element;
321 prev = next = new_element;
324 new_element->next = next;
325 next->prev = new_element;
328 new_element->prev = current;
329 current->next = new_element;
331 if (current == list->last)
332 list->last = new_element;
335 new_element->prev = prev;
336 prev->next = new_element;
337 if (ex_current_was_last)
338 list->last = new_element;
339 if (ex_current_was_cycle_pt)
340 cycle_pt = new_element;
343 current = new_element;
363 "new_element is NULL");
364 if (new_element->next)
368 if (list->empty ()) {
369 new_element->next = new_element;
370 new_element->prev = new_element;
371 list->last = new_element;
372 prev = next = new_element;
373 ex_current_was_last =
FALSE;
377 new_element->next = next;
378 next->prev = new_element;
381 new_element->prev = current;
382 current->next = new_element;
385 if (current == list->last)
386 list->last = new_element;
389 new_element->prev = prev;
390 prev->next = new_element;
391 if (ex_current_was_last) {
392 list->last = new_element;
393 ex_current_was_last =
FALSE;
417 "new_element is NULL");
418 if (new_element->next)
422 if (list->empty ()) {
423 new_element->next = new_element;
424 new_element->prev = new_element;
425 list->last = new_element;
426 prev = next = new_element;
429 prev->next = new_element;
430 new_element->prev = prev;
433 new_element->next = current;
434 current->prev = new_element;
438 new_element->next = next;
439 next->prev = new_element;
440 if (ex_current_was_last)
441 list->last = new_element;
442 if (ex_current_was_cycle_pt)
443 cycle_pt = new_element;
446 current = new_element;
466 "new_element is NULL");
467 if (new_element->next)
471 if (list->empty ()) {
472 new_element->next = new_element;
473 new_element->prev = new_element;
474 list->last = new_element;
475 prev = next = new_element;
476 ex_current_was_last =
TRUE;
480 prev->next = new_element;
481 new_element->prev = prev;
484 new_element->next = current;
485 current->prev = new_element;
490 new_element->next = next;
491 next->prev = new_element;
492 if (ex_current_was_last)
493 list->last = new_element;
515 "list_to_add is NULL");
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 current->next->prev = current;
530 if (current == list->last)
531 list->last = list_to_add->last;
532 list_to_add->last->next = next;
533 next->prev = list_to_add->last;
534 next = current->next;
537 prev->next = list_to_add->First ();
538 prev->next->prev = prev;
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;
544 next->prev = list_to_add->last;
548 list_to_add->last =
NULL;
569 "list_to_add is NULL");
572 if (!list_to_add->
empty ()) {
573 if (list->empty ()) {
574 list->last = list_to_add->last;
576 current = list->First ();
577 next = current->next;
578 ex_current_was_last =
FALSE;
581 prev->next = list_to_add->First ();
582 prev->next->prev = prev;
585 list_to_add->last->next = current;
586 current->prev = list_to_add->last;
589 list_to_add->last->next = next;
590 next->prev = list_to_add->last;
591 if (ex_current_was_last)
592 list->last = list_to_add->last;
593 if (ex_current_was_cycle_pt)
594 cycle_pt = prev->next;
596 current = prev->next;
597 next = current->next;
599 list_to_add->last =
NULL;
627 if (list->singleton()) {
629 prev = next = list->last =
NULL;
634 if (current == list->last) {
636 ex_current_was_last =
TRUE;
638 ex_current_was_last =
FALSE;
642 ex_current_was_cycle_pt = (current == cycle_pt) ?
TRUE :
FALSE;
643 extracted_link = current;
644 extracted_link->next =
NULL;
645 extracted_link->prev =
NULL;
647 return extracted_link;
666 current = list->First ();
668 next = current ? current->next :
NULL;
688 current = list->last;
689 prev = current ? current->prev :
NULL;
690 next = current ? current->next :
NULL;
717 ex_current_was_cycle_pt =
TRUE;
718 started_cycling =
FALSE;
738 return ((list->empty ()) || (current == list->First ()) || ((current ==
NULL) &&
739 (prev == list->last) &&
740 !ex_current_was_last));
760 return ((list->empty ()) || (current == list->last) || ((current ==
NULL) &&
761 (prev == list->last) &&
762 ex_current_was_last));
781 return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
801 return list->length ();
815 const void *,
const void *)) {
823 list->sort (comparator);
847 "new_element is NULL");
848 if (new_element->next)
852 if (this->at_last ()) {
853 this->add_after_stay_put (new_element);
856 if (this->at_first ()) {
857 this->add_before_stay_put (new_element);
858 list->last = new_element;
861 new_element->next = list->last->next;
862 new_element->prev = list->last;
863 list->last->next->prev = new_element;
864 list->last->next = new_element;
865 list->last = new_element;
877 #define QUOTE_IT( parm ) #parm 910 #define ELIST2IZEH_A( CLASSNAME ) \ 912 extern DLLSYM void CLASSNAME##_zapper( \ 915 #define ELIST2IZEH_B( CLASSNAME ) \ 924 class DLLSYM CLASSNAME##_LIST : public ELIST2 \ 927 CLASSNAME##_LIST():ELIST2() {} \ 931 const CLASSNAME##_LIST&) \ 932 { DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_LIST ), \ 936 { ELIST2::internal_clear( &CLASSNAME##_zapper ); } \ 938 ~CLASSNAME##_LIST() \ 942 void deep_copy(const CLASSNAME##_LIST* src_list, \ 943 CLASSNAME* (*copier)(const CLASSNAME*)); \ 946 const CLASSNAME##_LIST&) \ 947 { DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_LIST ), \ 950 #define ELIST2IZEH_C( CLASSNAME ) \ 966 class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR \ 969 CLASSNAME##_IT():ELIST2_ITERATOR(){} \ 972 CLASSNAME##_LIST* list):ELIST2_ITERATOR(list){} \ 975 { return (CLASSNAME*) ELIST2_ITERATOR::data(); } \ 977 CLASSNAME* data_relative( \ 979 { return (CLASSNAME*) ELIST2_ITERATOR::data_relative( offset ); } \ 981 CLASSNAME* forward() \ 982 { return (CLASSNAME*) ELIST2_ITERATOR::forward(); } \ 984 CLASSNAME* backward() \ 985 { return (CLASSNAME*) ELIST2_ITERATOR::backward(); } \ 987 CLASSNAME* extract() \ 988 { return (CLASSNAME*) ELIST2_ITERATOR::extract(); } \ 990 CLASSNAME* move_to_first() \ 991 { return (CLASSNAME*) ELIST2_ITERATOR::move_to_first(); } \ 993 CLASSNAME* move_to_last() \ 994 { return (CLASSNAME*) ELIST2_ITERATOR::move_to_last(); } \ 997 #define ELIST2IZEH( CLASSNAME ) \ 999 ELIST2IZEH_A( CLASSNAME ) \ 1001 ELIST2IZEH_B( CLASSNAME ) \ 1003 ELIST2IZEH_C( CLASSNAME ) 1010 #define ELIST2IZE( CLASSNAME ) \ 1021 DLLSYM void CLASSNAME##_zapper( \ 1022 ELIST2_LINK* link) \ 1024 delete (CLASSNAME *) link; \ 1028 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST* src_list, \ 1029 CLASSNAME* (*copier)(const CLASSNAME*)) { \ 1031 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST*>(src_list)); \ 1032 CLASSNAME##_IT to_it(this); \ 1034 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \ 1035 to_it.add_after_then_move((*copier)(from_it.data())); \
void add_after_stay_put(ELIST2_LINK *new_link)
void add_to_end(ELIST2_LINK *new_link)
void add_list_before(ELIST2 *list_to_add)
void add_list_after(ELIST2 *list_to_add)
void sort(int comparator(
const void *, const void *))
const ERRCODE BAD_PARAMETER
void add_before_then_move(ELIST2_LINK *new_link)
void add_before_stay_put(ELIST2_LINK *new_link)
const ERRCODE STILL_LINKED
void add_after_then_move(ELIST2_LINK *new_link)
void shallow_copy(ELIST2 *from_list)
const ERRCODE NULL_CURRENT
const ERRCODE NULL_OBJECT
BOOL8 current_extracted()
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
ELIST2_LINK * move_to_last()
void set_to_list(ELIST2 *list_to_iterate)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
ELIST2_LINK(const ELIST2_LINK &)
ELIST2_LINK * move_to_first()