50 data = next =
nullptr;
55 data = next =
nullptr;
60 data = next =
nullptr;
77 return last !=
nullptr ? last->
next :
nullptr;
89 void internal_deep_clear (
90 void (*zapper) (
void *));
100 return last !=
nullptr ? (last == last->
next) :
false;
105 last = from_list->
last;
108 void assign_to_sublist(
116 const void *,
const void *));
125 bool add_sorted(
int comparator(
const void*,
const void*),
126 bool unique,
void* new_data);
133 void set_subtract(
int comparator(
const void*,
const void*),
bool unique,
171 CLIST *list_to_iterate);
174 CLIST *list_to_iterate);
176 void add_after_then_move(
179 void add_after_stay_put(
182 void add_before_then_move(
185 void add_before_stay_put(
191 void add_list_before(
197 NO_LIST.
error (
"CLIST_ITERATOR::data", ABORT,
nullptr);
199 NULL_DATA.
error (
"CLIST_ITERATOR::data", ABORT,
nullptr);
201 return current->
data;
211 void *move_to_first();
213 void *move_to_last();
215 void mark_cycle_pt();
220 NO_LIST.
error (
"CLIST_ITERATOR::empty", ABORT,
nullptr);
222 return list->
empty ();
245 const void *,
const void *));
257 CLIST *list_to_iterate) {
259 if (!list_to_iterate)
260 BAD_PARAMETER.
error (
"CLIST_ITERATOR::set_to_list", ABORT,
261 "list_to_iterate is nullptr");
264 list = list_to_iterate;
266 current = list->First ();
267 next = current !=
nullptr ? current->
next :
nullptr;
269 started_cycling =
false;
270 ex_current_was_last =
false;
271 ex_current_was_cycle_pt =
false;
281 set_to_list(list_to_iterate);
297 NO_LIST.
error (
"CLIST_ITERATOR::add_after_then_move", ABORT,
nullptr);
299 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_after_then_move", ABORT,
300 "new_data is nullptr");
304 new_element->
data = new_data;
306 if (list->empty ()) {
307 new_element->
next = new_element;
308 list->last = new_element;
309 prev = next = new_element;
312 new_element->
next = next;
315 current->
next = new_element;
317 if (current == list->last)
318 list->last = new_element;
321 prev->
next = new_element;
322 if (ex_current_was_last)
323 list->last = new_element;
324 if (ex_current_was_cycle_pt)
325 cycle_pt = new_element;
328 current = new_element;
344 NO_LIST.
error (
"CLIST_ITERATOR::add_after_stay_put", ABORT,
nullptr);
346 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_after_stay_put", ABORT,
347 "new_data is nullptr");
351 new_element->
data = new_data;
353 if (list->empty ()) {
354 new_element->
next = new_element;
355 list->last = new_element;
356 prev = next = new_element;
357 ex_current_was_last =
false;
361 new_element->
next = next;
364 current->
next = new_element;
367 if (current == list->last)
368 list->last = new_element;
371 prev->
next = new_element;
372 if (ex_current_was_last) {
373 list->last = new_element;
374 ex_current_was_last =
false;
394 NO_LIST.
error (
"CLIST_ITERATOR::add_before_then_move", ABORT,
nullptr);
396 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_before_then_move", ABORT,
397 "new_data is nullptr");
401 new_element->
data = new_data;
403 if (list->empty ()) {
404 new_element->
next = new_element;
405 list->last = new_element;
406 prev = next = new_element;
409 prev->
next = new_element;
411 new_element->
next = current;
415 new_element->
next = next;
416 if (ex_current_was_last)
417 list->last = new_element;
418 if (ex_current_was_cycle_pt)
419 cycle_pt = new_element;
422 current = new_element;
438 NO_LIST.
error (
"CLIST_ITERATOR::add_before_stay_put", ABORT,
nullptr);
440 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_before_stay_put", ABORT,
441 "new_data is nullptr");
445 new_element->
data = new_data;
447 if (list->empty ()) {
448 new_element->
next = new_element;
449 list->last = new_element;
450 prev = next = new_element;
451 ex_current_was_last =
true;
455 prev->
next = new_element;
457 new_element->
next = current;
462 new_element->
next = next;
463 if (ex_current_was_last)
464 list->last = new_element;
481 NO_LIST.
error (
"CLIST_ITERATOR::add_list_after", ABORT,
nullptr);
483 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_list_after", ABORT,
484 "list_to_add is nullptr");
487 if (!list_to_add->
empty ()) {
488 if (list->empty ()) {
489 list->last = list_to_add->
last;
491 next = list->First ();
492 ex_current_was_last =
true;
498 if (current == list->last)
499 list->last = list_to_add->
last;
501 next = current->
next;
505 if (ex_current_was_last) {
506 list->last = list_to_add->
last;
507 ex_current_was_last =
false;
513 list_to_add->
last =
nullptr;
528 NO_LIST.
error (
"CLIST_ITERATOR::add_list_before", ABORT,
nullptr);
530 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_list_before", ABORT,
531 "list_to_add is nullptr");
534 if (!list_to_add->
empty ()) {
535 if (list->empty ()) {
536 list->last = list_to_add->
last;
538 current = list->First ();
539 next = current->
next;
540 ex_current_was_last =
false;
549 if (ex_current_was_last)
550 list->last = list_to_add->
last;
551 if (ex_current_was_cycle_pt)
552 cycle_pt = prev->
next;
554 current = prev->
next;
555 next = current->
next;
557 list_to_add->
last =
nullptr;
571 void *extracted_data;
575 NO_LIST.
error (
"CLIST_ITERATOR::extract", ABORT,
nullptr);
578 NULL_CURRENT.
error (
"CLIST_ITERATOR::extract",
582 if (list->singleton()) {
584 prev = next = list->last =
nullptr;
588 if (current == list->last) {
590 ex_current_was_last =
true;
592 ex_current_was_last =
false;
596 ex_current_was_cycle_pt = (current == cycle_pt);
597 extracted_data = current->data;
600 return extracted_data;
613 NO_LIST.
error (
"CLIST_ITERATOR::move_to_first", ABORT,
nullptr);
616 current = list->First ();
618 next = current !=
nullptr ? current->next :
nullptr;
619 return current !=
nullptr ? current->data :
nullptr;
636 NO_LIST.
error (
"CLIST_ITERATOR::mark_cycle_pt", ABORT,
nullptr);
642 ex_current_was_cycle_pt = TRUE;
643 started_cycling = FALSE;
656 NO_LIST.
error (
"CLIST_ITERATOR::at_first", ABORT,
nullptr);
660 return ((list->empty ()) || (current == list->First ()) || ((current ==
nullptr) &&
661 (prev == list->last) &&
662 !ex_current_was_last));
675 NO_LIST.
error (
"CLIST_ITERATOR::at_last", ABORT,
nullptr);
679 return ((list->empty ()) || (current == list->last) || ((current ==
nullptr) &&
680 (prev == list->last) &&
681 ex_current_was_last));
694 NO_LIST.
error (
"CLIST_ITERATOR::cycled_list", ABORT,
nullptr);
697 return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
711 NO_LIST.
error (
"CLIST_ITERATOR::length", ABORT,
nullptr);
714 return list->length ();
727 const void *,
const void *)) {
730 NO_LIST.
error (
"CLIST_ITERATOR::sort", ABORT,
nullptr);
733 list->sort (comparator);
753 NO_LIST.
error (
"CLIST_ITERATOR::add_to_end", ABORT,
nullptr);
755 BAD_PARAMETER.
error (
"CLIST_ITERATOR::add_to_end", ABORT,
756 "new_data is nullptr");
759 if (this->at_last ()) {
760 this->add_after_stay_put (new_data);
763 if (this->at_first ()) {
764 this->add_before_stay_put (new_data);
769 new_element->
data = new_data;
771 new_element->
next = list->last->
next;
772 list->last->
next = new_element;
773 list->last = new_element;
785 #define QUOTE_IT(parm) #parm 819 #define CLISTIZEH_A(CLASSNAME) \ 821 extern DLLSYM void CLASSNAME##_c1_zapper( \ 825 *CLASSNAME##_c1_copier( \ 828 #define CLISTIZEH_B(CLASSNAME) \ 839 class DLLSYM CLASSNAME##_CLIST : public CLIST { \ 841 CLASSNAME##_CLIST() : CLIST() {} \ 845 const CLASSNAME##_CLIST &) \ 847 DONT_CONSTRUCT_LIST_BY_COPY.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, \ 853 CLIST::internal_deep_clear(&CLASSNAME##_c1_zapper); \ 857 const CLASSNAME##_CLIST &) { \ 858 DONT_ASSIGN_LISTS.error(QUOTE_IT(CLASSNAME##_CLIST), ABORT, nullptr); \ 861 #define CLISTIZEH_C(CLASSNAME) \ 876 class DLLSYM CLASSNAME##_C_IT : public CLIST_ITERATOR { \ 878 CLASSNAME##_C_IT() : CLIST_ITERATOR() {} \ 880 CLASSNAME##_C_IT(CLASSNAME##_CLIST *list) : CLIST_ITERATOR(list) {} \ 882 CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \ 884 CLASSNAME *data_relative(int8_t offset) { \ 885 return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \ 888 CLASSNAME *forward() { return (CLASSNAME *)CLIST_ITERATOR::forward(); } \ 890 CLASSNAME *extract() { return (CLASSNAME *)CLIST_ITERATOR::extract(); } \ 892 CLASSNAME *move_to_first() { \ 893 return (CLASSNAME *)CLIST_ITERATOR::move_to_first(); \ 896 CLASSNAME *move_to_last() { \ 897 return (CLASSNAME *)CLIST_ITERATOR::move_to_last(); \ 901 #define CLISTIZEH(CLASSNAME) \ 903 CLISTIZEH_A(CLASSNAME) \ 905 CLISTIZEH_B(CLASSNAME) \ 907 CLISTIZEH_C(CLASSNAME) 913 #define CLISTIZE(CLASSNAME) \ 925 DLLSYM void CLASSNAME##_c1_zapper( \ 928 delete (CLASSNAME *)link; \ CLIST()
Definition: clst.h:81
CLIST_LINK * cycle_pt
Definition: clst.h:157
void add_after_then_move(void *new_data)
Definition: clst.h:291
void * data()
Definition: clst.h:194
~CLIST()
Definition: clst.h:85
void add_before_stay_put(void *new_data)
Definition: clst.h:432
CLIST_LINK * last
Definition: clst.h:74
bool current_extracted()
Definition: clst.h:225
bool cycled_list()
Definition: clst.h:691
void add_after_stay_put(void *new_data)
Definition: clst.h:338
bool ex_current_was_last
Definition: clst.h:153
bool at_first()
Definition: clst.h:653
void * data
Definition: clst.h:46
CLIST_LINK * prev
Definition: clst.h:150
CLIST_LINK * next
Definition: clst.h:45
CLIST_LINK()
Definition: clst.h:49
CLIST_LINK * next
Definition: clst.h:152
void mark_cycle_pt()
Definition: clst.h:633
int32_t length()
Definition: clst.h:708
bool singleton() const
Definition: clst.h:99
void shallow_copy(CLIST *from_list)
Definition: clst.h:103
CLIST_LINK * First()
Definition: clst.h:76
void * extract()
Definition: clst.h:570
CLIST_LINK * current
Definition: clst.h:151
bool ex_current_was_cycle_pt
Definition: clst.h:155
void * move_to_first()
Definition: clst.h:610
bool empty() const
Definition: clst.h:95
void add_before_then_move(void *new_data)
Definition: clst.h:388
void add_to_end(void *new_data)
Definition: clst.h:747
CLIST * list
Definition: clst.h:149
void operator=(const CLIST_LINK &)
Definition: clst.h:58
void set_to_list(CLIST *list_to_iterate)
Definition: clst.h:256
bool empty()
Definition: clst.h:217
CLIST_LINK(const CLIST_LINK &)
Definition: clst.h:53
bool at_last()
Definition: clst.h:672
void add_list_before(CLIST *list_to_add)
Definition: clst.h:525
CLIST_ITERATOR()
Definition: clst.h:166
void sort(int comparator(const void *, const void *))
Definition: clst.h:725
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37
bool started_cycling
Definition: clst.h:159
void add_list_after(CLIST *list_to_add)
Definition: clst.h:478
void assign_to_sublist(CLIST_ITERATOR *start_it, CLIST_ITERATOR *end_it)
Definition: clst.cpp:97