103 void internal_clear (
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) {
267 if (!list_to_iterate)
269 "list_to_iterate is NULL");
272 list = list_to_iterate;
274 current = list->First ();
275 next = current ? current->next : NULL;
277 started_cycling =
FALSE;
278 ex_current_was_last =
FALSE;
279 ex_current_was_cycle_pt =
FALSE;
308 "new_element is NULL");
309 if (new_element->next)
313 if (list->
empty ()) {
314 new_element->next = new_element;
315 new_element->prev = new_element;
316 list->last = new_element;
317 prev = next = new_element;
320 new_element->next = next;
321 next->prev = new_element;
324 new_element->prev = current;
325 current->next = new_element;
327 if (current == list->last)
328 list->last = new_element;
331 new_element->prev = prev;
332 prev->next = new_element;
333 if (ex_current_was_last)
334 list->last = new_element;
335 if (ex_current_was_cycle_pt)
336 cycle_pt = new_element;
339 current = new_element;
357 "new_element is NULL");
358 if (new_element->next)
362 if (list->
empty ()) {
363 new_element->next = new_element;
364 new_element->prev = new_element;
365 list->last = new_element;
366 prev = next = new_element;
367 ex_current_was_last =
FALSE;
371 new_element->next = next;
372 next->prev = new_element;
375 new_element->prev = current;
376 current->next = new_element;
379 if (current == list->last)
380 list->last = new_element;
383 new_element->prev = prev;
384 prev->next = new_element;
385 if (ex_current_was_last) {
386 list->last = new_element;
387 ex_current_was_last =
FALSE;
409 "new_element is NULL");
410 if (new_element->next)
414 if (list->
empty ()) {
415 new_element->next = new_element;
416 new_element->prev = new_element;
417 list->last = new_element;
418 prev = next = new_element;
421 prev->next = new_element;
422 new_element->prev = prev;
425 new_element->next = current;
426 current->prev = new_element;
430 new_element->next = next;
431 next->prev = new_element;
432 if (ex_current_was_last)
433 list->last = new_element;
434 if (ex_current_was_cycle_pt)
435 cycle_pt = new_element;
438 current = new_element;
456 "new_element is NULL");
457 if (new_element->next)
461 if (list->
empty ()) {
462 new_element->next = new_element;
463 new_element->prev = new_element;
464 list->last = new_element;
465 prev = next = new_element;
466 ex_current_was_last =
TRUE;
470 prev->next = new_element;
471 new_element->prev = prev;
474 new_element->next = current;
475 current->prev = new_element;
480 new_element->next = next;
481 next->prev = new_element;
482 if (ex_current_was_last)
483 list->last = new_element;
503 "list_to_add is NULL");
506 if (!list_to_add->
empty ()) {
507 if (list->
empty ()) {
508 list->last = list_to_add->last;
510 next = list->First ();
511 ex_current_was_last =
TRUE;
516 current->next = list_to_add->First ();
517 current->next->prev = current;
518 if (current == list->last)
519 list->last = list_to_add->last;
520 list_to_add->last->next = next;
521 next->prev = list_to_add->last;
522 next = current->next;
525 prev->next = list_to_add->First ();
526 prev->next->prev = prev;
527 if (ex_current_was_last) {
528 list->last = list_to_add->last;
529 ex_current_was_last =
FALSE;
531 list_to_add->last->next = next;
532 next->prev = list_to_add->last;
536 list_to_add->last = NULL;
555 "list_to_add is NULL");
558 if (!list_to_add->
empty ()) {
559 if (list->
empty ()) {
560 list->last = list_to_add->last;
562 current = list->First ();
563 next = current->next;
564 ex_current_was_last =
FALSE;
567 prev->next = list_to_add->First ();
568 prev->next->prev = prev;
571 list_to_add->last->next = current;
572 current->prev = list_to_add->last;
575 list_to_add->last->next = next;
576 next->prev = list_to_add->last;
577 if (ex_current_was_last)
578 list->last = list_to_add->last;
579 if (ex_current_was_cycle_pt)
580 cycle_pt = prev->next;
582 current = prev->next;
583 next = current->next;
585 list_to_add->last = NULL;
613 prev = next = list->last = NULL;
618 if (current == list->last) {
620 ex_current_was_last =
TRUE;
622 ex_current_was_last =
FALSE;
626 ex_current_was_cycle_pt = (current == cycle_pt) ?
TRUE :
FALSE;
627 extracted_link = current;
628 extracted_link->next = NULL;
629 extracted_link->prev = NULL;
631 return extracted_link;
648 current = list->First ();
650 next = current ? current->next : NULL;
668 current = list->last;
669 prev = current ? current->prev : NULL;
670 next = current ? current->next : NULL;
695 ex_current_was_cycle_pt =
TRUE;
696 started_cycling =
FALSE;
714 return ((list->
empty ()) || (current == list->First ()) || ((current == NULL) &&
715 (prev == list->last) &&
716 !ex_current_was_last));
734 return ((list->
empty ()) || (current == list->last) || ((current == NULL) &&
735 (prev == list->last) &&
736 ex_current_was_last));
753 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
785 const void *,
const void *)) {
791 list->
sort (comparator);
813 "new_element is NULL");
814 if (new_element->next)
824 list->last = new_element;
827 new_element->next = list->last->next;
828 new_element->prev = list->last;
829 list->last->next->prev = new_element;
830 list->last->next = new_element;
831 list->last = new_element;
843 #define QUOTE_IT( parm ) #parm
876 #define ELIST2IZEH_A( CLASSNAME ) \
878 extern DLLSYM void CLASSNAME##_zapper( \
881 #define ELIST2IZEH_B( CLASSNAME ) \
890 class DLLSYM CLASSNAME##_LIST : public ELIST2 \
893 CLASSNAME##_LIST():ELIST2() {} \
897 const CLASSNAME##_LIST&) \
898 { DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_LIST ), \
902 { ELIST2::internal_clear( &CLASSNAME##_zapper ); } \
904 ~CLASSNAME##_LIST() \
908 void deep_copy(const CLASSNAME##_LIST* src_list, \
909 CLASSNAME* (*copier)(const CLASSNAME*)); \
912 const CLASSNAME##_LIST&) \
913 { DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_LIST ), \
916 #define ELIST2IZEH_C( CLASSNAME ) \
932 class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR \
935 CLASSNAME##_IT():ELIST2_ITERATOR(){} \
938 CLASSNAME##_LIST* list):ELIST2_ITERATOR(list){} \
941 { return (CLASSNAME*) ELIST2_ITERATOR::data(); } \
943 CLASSNAME* data_relative( \
945 { return (CLASSNAME*) ELIST2_ITERATOR::data_relative( offset ); } \
947 CLASSNAME* forward() \
948 { return (CLASSNAME*) ELIST2_ITERATOR::forward(); } \
950 CLASSNAME* backward() \
951 { return (CLASSNAME*) ELIST2_ITERATOR::backward(); } \
953 CLASSNAME* extract() \
954 { return (CLASSNAME*) ELIST2_ITERATOR::extract(); } \
956 CLASSNAME* move_to_first() \
957 { return (CLASSNAME*) ELIST2_ITERATOR::move_to_first(); } \
959 CLASSNAME* move_to_last() \
960 { return (CLASSNAME*) ELIST2_ITERATOR::move_to_last(); } \
963 #define ELIST2IZEH( CLASSNAME ) \
965 ELIST2IZEH_A( CLASSNAME ) \
967 ELIST2IZEH_B( CLASSNAME ) \
969 ELIST2IZEH_C( CLASSNAME )
976 #define ELIST2IZE( CLASSNAME ) \
987 DLLSYM void CLASSNAME##_zapper( \
990 delete (CLASSNAME *) link; \
994 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST* src_list, \
995 CLASSNAME* (*copier)(const CLASSNAME*)) { \
997 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST*>(src_list)); \
998 CLASSNAME##_IT to_it(this); \
1000 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \
1001 to_it.add_after_then_move((*copier)(from_it.data())); \
void sort(int comparator(const void *, const void *))
void add_list_before(ELIST2 *list_to_add)
void sort(int comparator(const void *, const void *))
void add_before_then_move(ELIST2_LINK *new_link)
void add_list_after(ELIST2 *list_to_add)
const ERRCODE BAD_PARAMETER
const ERRCODE STILL_LINKED
void add_after_then_move(ELIST2_LINK *new_link)
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
void add_before_stay_put(ELIST2_LINK *new_link)
void shallow_copy(ELIST2 *from_list)
BOOL8 current_extracted()
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
ELIST2_LINK * move_to_last()
void set_to_list(ELIST2 *list_to_iterate)
ELIST2_LINK(const ELIST2_LINK &)
const ERRCODE NULL_CURRENT
ELIST2_LINK * move_to_first()
void add_to_end(ELIST2_LINK *new_link)
void add_after_stay_put(ELIST2_LINK *new_link)