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*),
159 BOOL8 ex_current_was_last;
161 BOOL8 ex_current_was_cycle_pt;
165 BOOL8 started_cycling;
182 void add_after_then_move(
185 void add_after_stay_put(
188 void add_before_then_move(
191 void add_before_stay_put(
197 void add_list_before(
224 void mark_cycle_pt();
231 return list->
empty ();
254 const void *,
const void *));
266 ELIST2 *list_to_iterate) {
268 if (!list_to_iterate)
270 "list_to_iterate is NULL");
273 list = list_to_iterate;
275 current = list->First ();
276 next = current ? current->next : NULL;
278 started_cycling =
FALSE;
279 ex_current_was_last =
FALSE;
280 ex_current_was_cycle_pt =
FALSE;
307 "new_element is NULL");
308 if (new_element->next)
312 if (list->
empty ()) {
313 new_element->next = new_element;
314 new_element->prev = new_element;
315 list->last = new_element;
316 prev = next = new_element;
319 new_element->next = next;
320 next->prev = new_element;
323 new_element->prev = current;
324 current->next = new_element;
326 if (current == list->last)
327 list->last = new_element;
330 new_element->prev = prev;
331 prev->next = new_element;
332 if (ex_current_was_last)
333 list->last = new_element;
334 if (ex_current_was_cycle_pt)
335 cycle_pt = new_element;
338 current = new_element;
355 "new_element is NULL");
356 if (new_element->next)
360 if (list->
empty ()) {
361 new_element->next = new_element;
362 new_element->prev = new_element;
363 list->last = new_element;
364 prev = next = new_element;
365 ex_current_was_last =
FALSE;
369 new_element->next = next;
370 next->prev = new_element;
373 new_element->prev = current;
374 current->next = new_element;
377 if (current == list->last)
378 list->last = new_element;
381 new_element->prev = prev;
382 prev->next = new_element;
383 if (ex_current_was_last) {
384 list->last = new_element;
385 ex_current_was_last =
FALSE;
406 "new_element is NULL");
407 if (new_element->next)
411 if (list->
empty ()) {
412 new_element->next = new_element;
413 new_element->prev = new_element;
414 list->last = new_element;
415 prev = next = new_element;
418 prev->next = new_element;
419 new_element->prev = prev;
422 new_element->next = current;
423 current->prev = new_element;
427 new_element->next = next;
428 next->prev = new_element;
429 if (ex_current_was_last)
430 list->last = new_element;
431 if (ex_current_was_cycle_pt)
432 cycle_pt = new_element;
435 current = new_element;
452 "new_element is NULL");
453 if (new_element->next)
457 if (list->
empty ()) {
458 new_element->next = new_element;
459 new_element->prev = new_element;
460 list->last = new_element;
461 prev = next = new_element;
462 ex_current_was_last =
TRUE;
466 prev->next = new_element;
467 new_element->prev = prev;
470 new_element->next = current;
471 current->prev = new_element;
476 new_element->next = next;
477 next->prev = new_element;
478 if (ex_current_was_last)
479 list->last = new_element;
499 "list_to_add is NULL");
502 if (!list_to_add->
empty ()) {
503 if (list->
empty ()) {
504 list->last = list_to_add->last;
506 next = list->First ();
507 ex_current_was_last =
TRUE;
512 current->next = list_to_add->First ();
513 current->next->prev = current;
514 if (current == list->last)
515 list->last = list_to_add->last;
516 list_to_add->last->next = next;
517 next->prev = list_to_add->last;
518 next = current->next;
521 prev->next = list_to_add->First ();
522 prev->next->prev = prev;
523 if (ex_current_was_last) {
524 list->last = list_to_add->last;
525 ex_current_was_last =
FALSE;
527 list_to_add->last->next = next;
528 next->prev = list_to_add->last;
532 list_to_add->last = NULL;
550 "list_to_add is NULL");
553 if (!list_to_add->
empty ()) {
554 if (list->
empty ()) {
555 list->last = list_to_add->last;
557 current = list->First ();
558 next = current->next;
559 ex_current_was_last =
FALSE;
562 prev->next = list_to_add->First ();
563 prev->next->prev = prev;
566 list_to_add->last->next = current;
567 current->prev = list_to_add->last;
570 list_to_add->last->next = next;
571 next->prev = list_to_add->last;
572 if (ex_current_was_last)
573 list->last = list_to_add->last;
574 if (ex_current_was_cycle_pt)
575 cycle_pt = prev->next;
577 current = prev->next;
578 next = current->next;
580 list_to_add->last = NULL;
607 prev = next = list->last = NULL;
612 if (current == list->last) {
614 ex_current_was_last =
TRUE;
616 ex_current_was_last =
FALSE;
620 ex_current_was_cycle_pt = (current == cycle_pt) ?
TRUE :
FALSE;
621 extracted_link = current;
622 extracted_link->next = NULL;
623 extracted_link->prev = NULL;
625 return extracted_link;
641 current = list->First ();
643 next = current ? current->next : NULL;
660 current = list->last;
661 prev = current ? current->prev : NULL;
662 next = current ? current->next : NULL;
686 ex_current_was_cycle_pt =
TRUE;
687 started_cycling =
FALSE;
704 return ((list->
empty ()) || (current == list->First ()) || ((current == NULL) &&
705 (prev == list->last) &&
706 !ex_current_was_last));
723 return ((list->
empty ()) || (current == list->last) || ((current == NULL) &&
724 (prev == list->last) &&
725 ex_current_was_last));
741 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
771 const void *,
const void *)) {
777 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 new_element->prev = list->last;
814 list->last->next->prev = new_element;
815 list->last->next = new_element;
816 list->last = new_element;
828 #define QUOTE_IT( parm ) #parm 861 #define ELIST2IZEH_A(CLASSNAME) \ 863 extern DLLSYM void CLASSNAME##_zapper( \ 866 #define ELIST2IZEH_B(CLASSNAME) \ 877 class DLLSYM CLASSNAME##_LIST : public ELIST2 { \ 879 CLASSNAME##_LIST() : ELIST2() {} \ 883 const CLASSNAME##_LIST &) \ 885 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, \ 891 ELIST2::internal_clear(&CLASSNAME##_zapper); \ 894 ~CLASSNAME##_LIST() \ 900 void deep_copy(const CLASSNAME##_LIST *src_list, \ 901 CLASSNAME *(*copier)(const CLASSNAME *)); \ 904 const CLASSNAME##_LIST &) { \ 905 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_LIST), ABORT, NULL); \ 908 #define ELIST2IZEH_C(CLASSNAME) \ 923 class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR { \ 925 CLASSNAME##_IT() : ELIST2_ITERATOR() {} \ 927 CLASSNAME##_IT(CLASSNAME##_LIST *list) : ELIST2_ITERATOR(list) {} \ 929 CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \ 931 CLASSNAME *data_relative(inT8 offset) { \ 932 return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \ 935 CLASSNAME *forward() { return (CLASSNAME *)ELIST2_ITERATOR::forward(); } \ 937 CLASSNAME *backward() { return (CLASSNAME *)ELIST2_ITERATOR::backward(); } \ 939 CLASSNAME *extract() { return (CLASSNAME *)ELIST2_ITERATOR::extract(); } \ 941 CLASSNAME *move_to_first() { \ 942 return (CLASSNAME *)ELIST2_ITERATOR::move_to_first(); \ 945 CLASSNAME *move_to_last() { \ 946 return (CLASSNAME *)ELIST2_ITERATOR::move_to_last(); \ 950 #define ELIST2IZEH(CLASSNAME) \ 952 ELIST2IZEH_A(CLASSNAME) \ 954 ELIST2IZEH_B(CLASSNAME) \ 956 ELIST2IZEH_C(CLASSNAME) 962 #define ELIST2IZE(CLASSNAME) \ 973 DLLSYM void CLASSNAME##_zapper( \ 976 delete (CLASSNAME *)link; \ 980 void CLASSNAME##_LIST::deep_copy(const CLASSNAME##_LIST *src_list, \ 981 CLASSNAME *(*copier)(const CLASSNAME *)) { \ 982 CLASSNAME##_IT from_it(const_cast<CLASSNAME##_LIST *>(src_list)); \ 983 CLASSNAME##_IT to_it(this); \ 985 for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward()) \ 986 to_it.add_after_then_move((*copier)(from_it.data())); \
const ERRCODE BAD_PARAMETER
void add_before_then_move(ELIST2_LINK *new_link)
void add_to_end(ELIST2_LINK *new_link)
const ERRCODE STILL_LINKED
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
void sort(int comparator(const void *, const void *))
ELIST2_LINK(const ELIST2_LINK &)
void add_after_stay_put(ELIST2_LINK *new_link)
void add_before_stay_put(ELIST2_LINK *new_link)
void shallow_copy(ELIST2 *from_list)
void sort(int comparator(const void *, const void *))
void operator=(const ELIST2_LINK &)
void set_to_list(ELIST2 *list_to_iterate)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
void add_list_after(ELIST2 *list_to_add)
ELIST2_LINK * move_to_first()
BOOL8 current_extracted()
void add_after_then_move(ELIST2_LINK *new_link)
ELIST2_LINK * move_to_last()
const ERRCODE NULL_CURRENT
void add_list_before(ELIST2 *list_to_add)