48 data = next =
nullptr;
53 data = next =
nullptr;
58 data = next =
nullptr;
87 void internal_deep_clear (
88 void (*zapper) (
void *));
103 last = from_list->last;
106 void assign_to_sublist(
110 int32_t length()
const;
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,
152 bool ex_current_was_last;
153 bool ex_current_was_cycle_pt;
154 bool started_cycling;
165 CLIST *list_to_iterate);
168 CLIST *list_to_iterate);
170 void add_after_then_move(
173 void add_after_stay_put(
176 void add_before_then_move(
179 void add_before_stay_put(
185 void add_list_before(
195 return current->data;
205 void *move_to_first();
207 void *move_to_last();
209 void mark_cycle_pt();
216 return list->
empty ();
239 const void *,
const void *));
251 CLIST *list_to_iterate) {
253 if (!list_to_iterate)
255 "list_to_iterate is nullptr");
258 list = list_to_iterate;
260 current = list->First ();
261 next = current !=
nullptr ? current->next :
nullptr;
263 started_cycling =
false;
264 ex_current_was_last =
false;
265 ex_current_was_cycle_pt =
false;
294 "new_data is nullptr");
298 new_element->data = new_data;
300 if (list->
empty ()) {
301 new_element->next = new_element;
302 list->last = new_element;
303 prev = next = new_element;
306 new_element->next = next;
309 current->next = new_element;
311 if (current == list->last)
312 list->last = new_element;
315 prev->next = new_element;
316 if (ex_current_was_last)
317 list->last = new_element;
318 if (ex_current_was_cycle_pt)
319 cycle_pt = new_element;
322 current = new_element;
341 "new_data is nullptr");
345 new_element->data = new_data;
347 if (list->
empty ()) {
348 new_element->next = new_element;
349 list->last = new_element;
350 prev = next = new_element;
351 ex_current_was_last =
false;
355 new_element->next = next;
358 current->next = new_element;
361 if (current == list->last)
362 list->last = new_element;
365 prev->next = new_element;
366 if (ex_current_was_last) {
367 list->last = new_element;
368 ex_current_was_last =
false;
391 "new_data is nullptr");
395 new_element->data = new_data;
397 if (list->
empty ()) {
398 new_element->next = new_element;
399 list->last = new_element;
400 prev = next = new_element;
403 prev->next = new_element;
405 new_element->next = current;
409 new_element->next = next;
410 if (ex_current_was_last)
411 list->last = new_element;
412 if (ex_current_was_cycle_pt)
413 cycle_pt = new_element;
416 current = new_element;
435 "new_data is nullptr");
439 new_element->data = new_data;
441 if (list->
empty ()) {
442 new_element->next = new_element;
443 list->last = new_element;
444 prev = next = new_element;
445 ex_current_was_last =
true;
449 prev->next = new_element;
451 new_element->next = current;
456 new_element->next = next;
457 if (ex_current_was_last)
458 list->last = new_element;
478 "list_to_add is nullptr");
481 if (!list_to_add->
empty ()) {
482 if (list->
empty ()) {
483 list->last = list_to_add->last;
485 next = list->First ();
486 ex_current_was_last =
true;
491 current->next = list_to_add->First ();
492 if (current == list->last)
493 list->last = list_to_add->last;
494 list_to_add->last->next = next;
495 next = current->next;
498 prev->next = list_to_add->First ();
499 if (ex_current_was_last) {
500 list->last = list_to_add->last;
501 ex_current_was_last =
false;
503 list_to_add->last->next = next;
507 list_to_add->last =
nullptr;
525 "list_to_add is nullptr");
528 if (!list_to_add->
empty ()) {
529 if (list->
empty ()) {
530 list->last = list_to_add->last;
532 current = list->First ();
533 next = current->next;
534 ex_current_was_last =
false;
537 prev->next = list_to_add->First ();
539 list_to_add->last->next = current;
542 list_to_add->last->next = next;
543 if (ex_current_was_last)
544 list->last = list_to_add->last;
545 if (ex_current_was_cycle_pt)
546 cycle_pt = prev->next;
548 current = prev->next;
549 next = current->next;
551 list_to_add->last =
nullptr;
565 void *extracted_data;
578 prev = next = list->last =
nullptr;
582 if (current == list->last) {
584 ex_current_was_last =
true;
586 ex_current_was_last =
false;
590 ex_current_was_cycle_pt = (current == cycle_pt);
591 extracted_data = current->data;
594 return extracted_data;
610 current = list->First ();
612 next = current !=
nullptr ? current->next :
nullptr;
613 return current !=
nullptr ? current->data :
nullptr;
636 ex_current_was_cycle_pt =
true;
637 started_cycling =
false;
654 return ((list->
empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
655 (prev == list->last) &&
656 !ex_current_was_last));
673 return ((list->
empty ()) || (current == list->last) || ((current ==
nullptr) &&
674 (prev == list->last) &&
675 ex_current_was_last));
691 return ((list->
empty ()) || ((current == cycle_pt) && started_cycling));
721const void *,
const void *)) {
727 list->
sort (comparator);
750 "new_data is nullptr");
763 new_element->data = new_data;
765 new_element->next = list->last->next;
766 list->last->next = new_element;
767 list->last = new_element;
779#define QUOTE_IT(parm) #parm
813#define CLISTIZEH_A(CLASSNAME) \
815 extern DLLSYM void CLASSNAME##_c1_zapper( \
819 *CLASSNAME##_c1_copier( \
822#define CLISTIZEH_B(CLASSNAME) \
833 class DLLSYM CLASSNAME##_CLIST : public CLIST { \
835 CLASSNAME##_CLIST() : CLIST() {} \
839 const CLASSNAME##_CLIST &) \
841 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, \
847 CLIST::internal_deep_clear(&CLASSNAME##_c1_zapper); \
851 const CLASSNAME##_CLIST &) { \
852 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, nullptr); \
855#define CLISTIZEH_C(CLASSNAME) \
870 class DLLSYM CLASSNAME##_C_IT : public CLIST_ITERATOR { \
872 CLASSNAME##_C_IT() : CLIST_ITERATOR() {} \
874 CLASSNAME##_C_IT(CLASSNAME##_CLIST *list) : CLIST_ITERATOR(list) {} \
876 CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \
878 CLASSNAME *data_relative(int8_t offset) { \
879 return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \
882 CLASSNAME *forward() { return (CLASSNAME *)CLIST_ITERATOR::forward(); } \
884 CLASSNAME *extract() { return (CLASSNAME *)CLIST_ITERATOR::extract(); } \
886 CLASSNAME *move_to_first() { \
887 return (CLASSNAME *)CLIST_ITERATOR::move_to_first(); \
890 CLASSNAME *move_to_last() { \
891 return (CLASSNAME *)CLIST_ITERATOR::move_to_last(); \
895#define CLISTIZEH(CLASSNAME) \
897 CLISTIZEH_A(CLASSNAME) \
899 CLISTIZEH_B(CLASSNAME) \
901 CLISTIZEH_C(CLASSNAME)
907#define CLISTIZE(CLASSNAME) \
919 DLLSYM void CLASSNAME##_c1_zapper( \
922 delete (CLASSNAME *)link; \
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
constexpr ERRCODE BAD_PARAMETER("List parameter error")
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
CLIST_LINK(const CLIST_LINK &)
void operator=(const CLIST_LINK &)
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
void sort(int comparator(const void *, const void *))
void shallow_copy(CLIST *from_list)
void add_list_after(CLIST *list_to_add)
void sort(int comparator(const void *, const void *))
void add_to_end(void *new_data)
void add_after_stay_put(void *new_data)
void add_before_stay_put(void *new_data)
void add_before_then_move(void *new_data)
void set_to_list(CLIST *list_to_iterate)
void add_after_then_move(void *new_data)
void add_list_before(CLIST *list_to_add)
void error(const char *caller, TessErrorLogCode action, const char *format,...) const