51 data =
next =
nullptr;
83 void internal_deep_clear(
84 void (*zapper)(
void *));
99 last = from_list->last;
102 void assign_to_sublist(
108 if (
last !=
nullptr) {
119 const void *,
const void *));
128 bool add_sorted(
int comparator(
const void *,
const void *),
bool unique,
void *new_data);
135 void set_subtract(
int comparator(
const void *,
const void *),
bool unique,
CLIST *minuend,
154 bool ex_current_was_last;
155 bool ex_current_was_cycle_pt;
156 bool started_cycling;
167 CLIST *list_to_iterate);
170 CLIST *list_to_iterate);
172 void add_after_then_move(
175 void add_after_stay_put(
178 void add_before_then_move(
181 void add_before_stay_put(
187 void add_list_before(
196 return current->data;
206 void *move_to_first();
208 void *move_to_last();
210 void mark_cycle_pt();
213 return list->
empty();
220 bool at_first()
const;
222 bool at_last()
const;
224 bool cycled_list()
const;
232 int32_t length()
const;
236 const void *,
const void *));
247 CLIST *list_to_iterate) {
248 list = list_to_iterate;
250 current = list->First();
251 next = current !=
nullptr ? current->next :
nullptr;
253 started_cycling =
false;
254 ex_current_was_last =
false;
255 ex_current_was_cycle_pt =
false;
284 new_element->data = new_data;
287 new_element->next = new_element;
288 list->last = new_element;
289 prev = next = new_element;
291 new_element->next = next;
294 current->next = new_element;
296 if (current == list->last) {
297 list->last = new_element;
300 prev->next = new_element;
301 if (ex_current_was_last) {
302 list->last = new_element;
304 if (ex_current_was_cycle_pt) {
305 cycle_pt = new_element;
309 current = new_element;
328 new_element->data = new_data;
331 new_element->next = new_element;
332 list->last = new_element;
333 prev = next = new_element;
334 ex_current_was_last =
false;
337 new_element->next = next;
340 current->next = new_element;
341 if (prev == current) {
344 if (current == list->last) {
345 list->last = new_element;
348 prev->next = new_element;
349 if (ex_current_was_last) {
350 list->last = new_element;
351 ex_current_was_last =
false;
374 new_element->data = new_data;
377 new_element->next = new_element;
378 list->last = new_element;
379 prev = next = new_element;
381 prev->next = new_element;
383 new_element->next = current;
386 new_element->next = next;
387 if (ex_current_was_last) {
388 list->last = new_element;
390 if (ex_current_was_cycle_pt) {
391 cycle_pt = new_element;
395 current = new_element;
414 new_element->data = new_data;
417 new_element->next = new_element;
418 list->last = new_element;
419 prev = next = new_element;
420 ex_current_was_last =
true;
423 prev->next = new_element;
425 new_element->next = current;
426 if (next == current) {
430 new_element->next = next;
431 if (ex_current_was_last) {
432 list->last = new_element;
448 if (!list_to_add->
empty()) {
450 list->last = list_to_add->last;
452 next = list->First();
453 ex_current_was_last =
true;
457 current->next = list_to_add->First();
458 if (current == list->last) {
459 list->last = list_to_add->last;
461 list_to_add->last->next = next;
462 next = current->next;
464 prev->next = list_to_add->First();
465 if (ex_current_was_last) {
466 list->last = list_to_add->last;
467 ex_current_was_last =
false;
469 list_to_add->last->next = next;
473 list_to_add->last =
nullptr;
486 if (!list_to_add->
empty()) {
488 list->last = list_to_add->last;
490 current = list->First();
491 next = current->next;
492 ex_current_was_last =
false;
494 prev->next = list_to_add->First();
496 list_to_add->last->next = current;
498 list_to_add->last->next = next;
499 if (ex_current_was_last) {
500 list->last = list_to_add->last;
502 if (ex_current_was_cycle_pt) {
503 cycle_pt = prev->next;
506 current = prev->next;
507 next = current->next;
509 list_to_add->last =
nullptr;
532 prev = next = list->last =
nullptr;
536 if (current == list->last) {
538 ex_current_was_last =
true;
540 ex_current_was_last =
false;
544 ex_current_was_cycle_pt = (current == cycle_pt);
545 auto extracted_data = current->data;
548 return extracted_data;
559 current = list->First();
561 next = current !=
nullptr ? current->next :
nullptr;
562 return current !=
nullptr ? current->data :
nullptr;
586 ex_current_was_cycle_pt =
true;
588 started_cycling =
false;
600 return ((list->
empty()) || (current == list->First()) ||
601 ((current ==
nullptr) && (prev == list->last) &&
602 !ex_current_was_last));
614 return ((list->
empty()) || (current == list->last) ||
615 ((current ==
nullptr) && (prev == list->last) &&
616 ex_current_was_last));
627 return ((list->
empty()) || ((current == cycle_pt) && started_cycling));
650 const void *,
const void *)) {
651 list->
sort(comparator);
684 new_element->data = new_data;
686 new_element->next = list->last->next;
687 list->last->next = new_element;
688 list->last = new_element;
693template <
typename CLASSNAME>
705#define CLISTIZEH(CLASSNAME) \
706 class CLASSNAME##_CLIST : public X_CLIST<CLASSNAME> { \
707 using X_CLIST<CLASSNAME>::X_CLIST; \
709 struct CLASSNAME##_C_IT : X_ITER<CLIST_ITERATOR, CLASSNAME> { \
710 using X_ITER<CLIST_ITERATOR, CLASSNAME>::X_ITER; \
constexpr ERRCODE BAD_PARAMETER("List parameter error")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void operator=(const CLIST_LINK &)=delete
CLIST_LINK(const CLIST_LINK &)=delete
void sort(int comparator(const void *, const void *))
void shallow_copy(CLIST *from_list)
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
void internal_deep_clear(void(*zapper)(void *))
void add_to_end(void *new_data)
void add_after_stay_put(void *new_data)
void add_before_then_move(void *new_data)
bool current_extracted() const
void add_list_after(CLIST *list_to_add)
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 sort(int comparator(const void *, const void *))
void add_before_stay_put(void *new_data)
X_CLIST(const X_CLIST &)=delete
X_CLIST & operator=(const X_CLIST &)=delete
void error(const char *caller, TessErrorLogCode action, const char *format,...) const __attribute__((format(gnu_printf