48 data = next =
nullptr;
53 data = next =
nullptr;
58 data = next =
nullptr;
75 return last !=
nullptr ? last->next :
nullptr;
87 void internal_deep_clear (
88 void (*zapper) (
void *));
98 return last !=
nullptr ? (last == last->next) :
false;
103 last = from_list->last;
106 void assign_to_sublist(
114 const void *,
const void *));
123 bool add_sorted(
int comparator(
const void*,
const void*),
124 bool unique,
void* new_data);
131 void set_subtract(
int comparator(
const void*,
const void*),
bool unique,
151 bool ex_current_was_last;
153 bool ex_current_was_cycle_pt;
157 bool started_cycling;
169 CLIST *list_to_iterate);
172 CLIST *list_to_iterate);
174 void add_after_then_move(
177 void add_after_stay_put(
180 void add_before_then_move(
183 void add_before_stay_put(
189 void add_list_before(
199 return current->data;
209 void *move_to_first();
211 void *move_to_last();
213 void mark_cycle_pt();
220 return list->
empty ();
243 const void *,
const void *));
255 CLIST *list_to_iterate) {
257 if (!list_to_iterate)
259 "list_to_iterate is nullptr");
262 list = list_to_iterate;
264 current = list->First ();
265 next = current !=
nullptr ? current->next :
nullptr;
267 started_cycling =
false;
268 ex_current_was_last =
false;
269 ex_current_was_cycle_pt =
false;
279 set_to_list(list_to_iterate);
298 "new_data is nullptr");
302 new_element->data = new_data;
304 if (list->empty ()) {
305 new_element->next = new_element;
306 list->last = new_element;
307 prev = next = new_element;
310 new_element->next = next;
313 current->next = new_element;
315 if (current == list->last)
316 list->last = new_element;
319 prev->next = new_element;
320 if (ex_current_was_last)
321 list->last = new_element;
322 if (ex_current_was_cycle_pt)
323 cycle_pt = new_element;
326 current = new_element;
345 "new_data is nullptr");
349 new_element->data = new_data;
351 if (list->empty ()) {
352 new_element->next = new_element;
353 list->last = new_element;
354 prev = next = new_element;
355 ex_current_was_last =
false;
359 new_element->next = next;
362 current->next = new_element;
365 if (current == list->last)
366 list->last = new_element;
369 prev->next = new_element;
370 if (ex_current_was_last) {
371 list->last = new_element;
372 ex_current_was_last =
false;
395 "new_data is nullptr");
399 new_element->data = new_data;
401 if (list->empty ()) {
402 new_element->next = new_element;
403 list->last = new_element;
404 prev = next = new_element;
407 prev->next = new_element;
409 new_element->next = current;
413 new_element->next = next;
414 if (ex_current_was_last)
415 list->last = new_element;
416 if (ex_current_was_cycle_pt)
417 cycle_pt = new_element;
420 current = new_element;
439 "new_data is nullptr");
443 new_element->data = new_data;
445 if (list->empty ()) {
446 new_element->next = new_element;
447 list->last = new_element;
448 prev = next = new_element;
449 ex_current_was_last =
true;
453 prev->next = new_element;
455 new_element->next = current;
460 new_element->next = next;
461 if (ex_current_was_last)
462 list->last = new_element;
482 "list_to_add is nullptr");
485 if (!list_to_add->
empty ()) {
486 if (list->empty ()) {
487 list->last = list_to_add->last;
489 next = list->First ();
490 ex_current_was_last =
true;
495 current->next = list_to_add->First ();
496 if (current == list->last)
497 list->last = list_to_add->last;
498 list_to_add->last->next = next;
499 next = current->next;
502 prev->next = list_to_add->First ();
503 if (ex_current_was_last) {
504 list->last = list_to_add->last;
505 ex_current_was_last =
false;
507 list_to_add->last->next = next;
511 list_to_add->last =
nullptr;
529 "list_to_add is nullptr");
532 if (!list_to_add->
empty ()) {
533 if (list->empty ()) {
534 list->last = list_to_add->last;
536 current = list->First ();
537 next = current->next;
538 ex_current_was_last =
false;
541 prev->next = list_to_add->First ();
543 list_to_add->last->next = current;
546 list_to_add->last->next = next;
547 if (ex_current_was_last)
548 list->last = list_to_add->last;
549 if (ex_current_was_cycle_pt)
550 cycle_pt = prev->next;
552 current = prev->next;
553 next = current->next;
555 list_to_add->last =
nullptr;
569 void *extracted_data;
580 if (list->singleton()) {
582 prev = next = list->last =
nullptr;
586 if (current == list->last) {
588 ex_current_was_last =
true;
590 ex_current_was_last =
false;
594 ex_current_was_cycle_pt = (current == cycle_pt);
595 extracted_data = current->data;
598 return extracted_data;
614 current = list->First ();
616 next = current !=
nullptr ? current->next :
nullptr;
617 return current !=
nullptr ? current->data :
nullptr;
640 ex_current_was_cycle_pt =
true;
641 started_cycling =
false;
658 return ((list->empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
659 (prev == list->last) &&
660 !ex_current_was_last));
677 return ((list->empty ()) || (current == list->last) || ((current ==
nullptr) &&
678 (prev == list->last) &&
679 ex_current_was_last));
695 return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
712 return list->length ();
725 const void *,
const void *)) {
731 list->sort (comparator);
754 "new_data is nullptr");
757 if (this->at_last ()) {
758 this->add_after_stay_put (new_data);
761 if (this->at_first ()) {
762 this->add_before_stay_put (new_data);
767 new_element->data = new_data;
769 new_element->next = list->last->next;
770 list->last->next = new_element;
771 list->last = new_element;
783 #define QUOTE_IT(parm) #parm 817 #define CLISTIZEH_A(CLASSNAME) \ 819 extern DLLSYM void CLASSNAME##_c1_zapper( \ 823 *CLASSNAME##_c1_copier( \ 826 #define CLISTIZEH_B(CLASSNAME) \ 837 class DLLSYM CLASSNAME##_CLIST : public CLIST { \ 839 CLASSNAME##_CLIST() : CLIST() {} \ 843 const CLASSNAME##_CLIST &) \ 845 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, \ 851 CLIST::internal_deep_clear(&CLASSNAME##_c1_zapper); \ 855 const CLASSNAME##_CLIST &) { \ 856 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, nullptr); \ 859 #define CLISTIZEH_C(CLASSNAME) \ 874 class DLLSYM CLASSNAME##_C_IT : public CLIST_ITERATOR { \ 876 CLASSNAME##_C_IT() : CLIST_ITERATOR() {} \ 878 CLASSNAME##_C_IT(CLASSNAME##_CLIST *list) : CLIST_ITERATOR(list) {} \ 880 CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \ 882 CLASSNAME *data_relative(int8_t offset) { \ 883 return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \ 886 CLASSNAME *forward() { return (CLASSNAME *)CLIST_ITERATOR::forward(); } \ 888 CLASSNAME *extract() { return (CLASSNAME *)CLIST_ITERATOR::extract(); } \ 890 CLASSNAME *move_to_first() { \ 891 return (CLASSNAME *)CLIST_ITERATOR::move_to_first(); \ 894 CLASSNAME *move_to_last() { \ 895 return (CLASSNAME *)CLIST_ITERATOR::move_to_last(); \ 899 #define CLISTIZEH(CLASSNAME) \ 901 CLISTIZEH_A(CLASSNAME) \ 903 CLISTIZEH_B(CLASSNAME) \ 905 CLISTIZEH_C(CLASSNAME) 911 #define CLISTIZE(CLASSNAME) \ 923 DLLSYM void CLASSNAME##_c1_zapper( \ 926 delete (CLASSNAME *)link; \
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
constexpr ERRCODE BAD_PARAMETER("List parameter error")
void add_before_then_move(void *new_data)
void add_after_then_move(void *new_data)
void shallow_copy(CLIST *from_list)
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
void add_after_stay_put(void *new_data)
void set_to_list(CLIST *list_to_iterate)
CLIST_LINK(const CLIST_LINK &)
void add_before_stay_put(void *new_data)
void operator=(const CLIST_LINK &)
void add_list_after(CLIST *list_to_add)
void add_to_end(void *new_data)
void sort(int comparator(
const void *, const void *))
void add_list_before(CLIST *list_to_add)