69 prev =
next =
nullptr;
76 prev =
next =
nullptr;
97 void internal_clear(
void (*zapper)(
void *));
109 last = from_list->last;
116 void assign_to_sublist(
123 if (
last !=
nullptr) {
134 const void *,
const void *));
141 void add_sorted(
int comparator(
const void *,
const void *),
ELIST2_LINK *new_link);
159 bool ex_current_was_last;
160 bool ex_current_was_cycle_pt;
161 bool started_cycling;
173 void add_after_then_move(
176 void add_after_stay_put(
179 void add_before_then_move(
182 void add_before_stay_put(
188 void add_list_before(
217 void mark_cycle_pt();
225 return list->
empty();
232 bool at_first()
const;
234 bool at_last()
const;
236 bool cycled_list()
const;
251 const void *,
const void *));
266 ELIST2 *list_to_iterate) {
268 if (!list_to_iterate) {
273 list = list_to_iterate;
275 current = list->First();
276 next = current ? current->next :
nullptr;
278 started_cycling =
false;
279 ex_current_was_last =
false;
280 ex_current_was_cycle_pt =
false;
289inline ELIST2_ITERATOR::ELIST2_ITERATOR(
ELIST2 *list_to_iterate) {
309 if (new_element->next) {
315 new_element->next = new_element;
316 new_element->prev = new_element;
317 list->last = new_element;
318 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;
336 if (ex_current_was_cycle_pt) {
337 cycle_pt = new_element;
341 current = new_element;
360 if (new_element->next) {
366 new_element->next = new_element;
367 new_element->prev = new_element;
368 list->last = new_element;
369 prev = next = new_element;
370 ex_current_was_last =
false;
373 new_element->next = next;
374 next->prev = new_element;
377 new_element->prev = current;
378 current->next = new_element;
379 if (prev == current) {
382 if (current == list->last) {
383 list->last = new_element;
386 new_element->prev = prev;
387 prev->next = new_element;
388 if (ex_current_was_last) {
389 list->last = new_element;
390 ex_current_was_last =
false;
413 if (new_element->next) {
419 new_element->next = new_element;
420 new_element->prev = new_element;
421 list->last = new_element;
422 prev = next = new_element;
424 prev->next = new_element;
425 new_element->prev = prev;
428 new_element->next = current;
429 current->prev = new_element;
432 new_element->next = next;
433 next->prev = new_element;
434 if (ex_current_was_last) {
435 list->last = new_element;
437 if (ex_current_was_cycle_pt) {
438 cycle_pt = new_element;
442 current = new_element;
461 if (new_element->next) {
467 new_element->next = new_element;
468 new_element->prev = new_element;
469 list->last = new_element;
470 prev = next = new_element;
471 ex_current_was_last =
true;
474 prev->next = new_element;
475 new_element->prev = prev;
478 new_element->next = current;
479 current->prev = new_element;
480 if (next == current) {
484 new_element->next = next;
485 next->prev = new_element;
486 if (ex_current_was_last) {
487 list->last = new_element;
512 if (!list_to_add->
empty()) {
514 list->last = list_to_add->last;
516 next = list->First();
517 ex_current_was_last =
true;
521 current->next = list_to_add->First();
522 current->next->prev = current;
523 if (current == list->last) {
524 list->last = list_to_add->last;
526 list_to_add->last->next = next;
527 next->prev = list_to_add->last;
528 next = current->next;
530 prev->next = list_to_add->First();
531 prev->next->prev = prev;
532 if (ex_current_was_last) {
533 list->last = list_to_add->last;
534 ex_current_was_last =
false;
536 list_to_add->last->next = next;
537 next->prev = list_to_add->last;
541 list_to_add->last =
nullptr;
563 if (!list_to_add->
empty()) {
565 list->last = list_to_add->last;
567 current = list->First();
568 next = current->next;
569 ex_current_was_last =
false;
571 prev->next = list_to_add->First();
572 prev->next->prev = prev;
575 list_to_add->last->next = current;
576 current->prev = list_to_add->last;
578 list_to_add->last->next = next;
579 next->prev = list_to_add->last;
580 if (ex_current_was_last) {
581 list->last = list_to_add->last;
583 if (ex_current_was_cycle_pt) {
584 cycle_pt = prev->next;
587 current = prev->next;
588 next = current->next;
590 list_to_add->last =
nullptr;
618 prev = next = list->last =
nullptr;
623 if (current == list->last) {
625 ex_current_was_last =
true;
627 ex_current_was_last =
false;
631 ex_current_was_cycle_pt = (current == cycle_pt);
632 extracted_link = current;
633 extracted_link->next =
nullptr;
634 extracted_link->prev =
nullptr;
636 return extracted_link;
653 current = list->First();
655 next = current ? current->next :
nullptr;
673 current = list->last;
674 prev = current ? current->prev :
nullptr;
675 next = current ? current->next :
nullptr;
700 ex_current_was_cycle_pt =
true;
702 started_cycling =
false;
720 return ((list->
empty()) || (current == list->First()) ||
721 ((current ==
nullptr) && (prev == list->last) &&
722 !ex_current_was_last));
740 return ((list->
empty()) || (current == list->last) ||
741 ((current ==
nullptr) && (prev == list->last) &&
742 ex_current_was_last));
759 return ((list->
empty()) || ((current == cycle_pt) && started_cycling));
771 const void *,
const void *)) {
778 list->
sort(comparator);
801 if (new_element->next) {
811 list->last = new_element;
813 new_element->next = list->last->next;
814 new_element->prev = list->last;
815 list->last->next->prev = new_element;
816 list->last->next = new_element;
817 list->last = new_element;
822#define ELIST2IZEH(CLASSNAME) \
823 class CLASSNAME##_LIST : public X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME> { \
824 using X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME>::X_LIST; \
826 struct CLASSNAME##_IT : X_ITER<ELIST2_ITERATOR, CLASSNAME> { \
827 using X_ITER<ELIST2_ITERATOR, CLASSNAME>::X_ITER; \
828 CLASSNAME *backward() { \
829 return reinterpret_cast<CLASSNAME *>(ELIST2_ITERATOR::backward()); \
constexpr ERRCODE BAD_PARAMETER("List parameter error")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
ELIST2_LINK(const ELIST2_LINK &)=delete
void operator=(const ELIST2_LINK &)
void sort(int comparator(const void *, const void *))
void shallow_copy(ELIST2 *from_list)
void assign_to_sublist(ELIST2_ITERATOR *start_it, ELIST2_ITERATOR *end_it)
void internal_deep_copy(ELIST2_LINK *(*copier)(ELIST2_LINK *), const ELIST2 *list)
void add_after_stay_put(ELIST2_LINK *new_link)
void add_before_then_move(ELIST2_LINK *new_link)
void add_list_after(ELIST2 *list_to_add)
void add_list_before(ELIST2 *list_to_add)
ELIST2_LINK * move_to_first()
void add_after_then_move(ELIST2_LINK *new_link)
void sort(int comparator(const void *, const void *))
void set_to_list(ELIST2 *list_to_iterate)
ELIST2_LINK * move_to_last()
void add_before_stay_put(ELIST2_LINK *new_link)
void add_to_end(ELIST2_LINK *new_link)
bool current_extracted() const
void error(const char *caller, TessErrorLogCode action, const char *format,...) const __attribute__((format(gnu_printf