tesseract  4.1.0
CLIST_ITERATOR Class Reference

#include <clst.h>

Public Member Functions

 CLIST_ITERATOR ()
 
 CLIST_ITERATOR (CLIST *list_to_iterate)
 
void set_to_list (CLIST *list_to_iterate)
 
void add_after_then_move (void *new_data)
 
void add_after_stay_put (void *new_data)
 
void add_before_then_move (void *new_data)
 
void add_before_stay_put (void *new_data)
 
void add_list_after (CLIST *list_to_add)
 
void add_list_before (CLIST *list_to_add)
 
void * data ()
 
void * data_relative (int8_t offset)
 
void * forward ()
 
void * extract ()
 
void * move_to_first ()
 
void * move_to_last ()
 
void mark_cycle_pt ()
 
bool empty ()
 
bool current_extracted ()
 
bool at_first ()
 
bool at_last ()
 
bool cycled_list ()
 
void add_to_end (void *new_data)
 
void exchange (CLIST_ITERATOR *other_it)
 
int32_t length ()
 
void sort (int comparator( const void *, const void *))
 

Friends

void CLIST::assign_to_sublist (CLIST_ITERATOR *, CLIST_ITERATOR *)
 

Detailed Description

Definition at line 143 of file clst.h.

Constructor & Destructor Documentation

CLIST_ITERATOR::CLIST_ITERATOR ( )
inline

Definition at line 164 of file clst.h.

164  { //constructor
165  list = nullptr;
166  } //unassigned list
CLIST_ITERATOR::CLIST_ITERATOR ( CLIST list_to_iterate)
inline

Definition at line 278 of file clst.h.

278  {
279  set_to_list(list_to_iterate);
280 }
void set_to_list(CLIST *list_to_iterate)
Definition: clst.h:254

Member Function Documentation

void CLIST_ITERATOR::add_after_stay_put ( void *  new_data)
inline

Definition at line 336 of file clst.h.

337  {
338  CLIST_LINK *new_element;
339 
340  #ifndef NDEBUG
341  if (!list)
342  NO_LIST.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, nullptr);
343  if (!new_data)
344  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_stay_put", ABORT,
345  "new_data is nullptr");
346  #endif
347 
348  new_element = new CLIST_LINK;
349  new_element->data = new_data;
350 
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;
356  current = nullptr;
357  }
358  else {
359  new_element->next = next;
360 
361  if (current) { //not extracted
362  current->next = new_element;
363  if (prev == current)
364  prev = new_element;
365  if (current == list->last)
366  list->last = new_element;
367  }
368  else { //current extracted
369  prev->next = new_element;
370  if (ex_current_was_last) {
371  list->last = new_element;
372  ex_current_was_last = false;
373  }
374  }
375  next = new_element;
376  }
377 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_after_then_move ( void *  new_data)
inline

Definition at line 289 of file clst.h.

290  {
291  CLIST_LINK *new_element;
292 
293  #ifndef NDEBUG
294  if (!list)
295  NO_LIST.error ("CLIST_ITERATOR::add_after_then_move", ABORT, nullptr);
296  if (!new_data)
297  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_then_move", ABORT,
298  "new_data is nullptr");
299  #endif
300 
301  new_element = new CLIST_LINK;
302  new_element->data = new_data;
303 
304  if (list->empty ()) {
305  new_element->next = new_element;
306  list->last = new_element;
307  prev = next = new_element;
308  }
309  else {
310  new_element->next = next;
311 
312  if (current) { //not extracted
313  current->next = new_element;
314  prev = current;
315  if (current == list->last)
316  list->last = new_element;
317  }
318  else { //current extracted
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;
324  }
325  }
326  current = new_element;
327 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_before_stay_put ( void *  new_data)
inline

Definition at line 430 of file clst.h.

431  {
432  CLIST_LINK *new_element;
433 
434  #ifndef NDEBUG
435  if (!list)
436  NO_LIST.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
437  if (!new_data)
438  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_stay_put", ABORT,
439  "new_data is nullptr");
440  #endif
441 
442  new_element = new CLIST_LINK;
443  new_element->data = new_data;
444 
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;
450  current = nullptr;
451  }
452  else {
453  prev->next = new_element;
454  if (current) { //not extracted
455  new_element->next = current;
456  if (next == current)
457  next = new_element;
458  }
459  else { //current extracted
460  new_element->next = next;
461  if (ex_current_was_last)
462  list->last = new_element;
463  }
464  prev = new_element;
465  }
466 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_before_then_move ( void *  new_data)
inline

Definition at line 386 of file clst.h.

387  {
388  CLIST_LINK *new_element;
389 
390  #ifndef NDEBUG
391  if (!list)
392  NO_LIST.error ("CLIST_ITERATOR::add_before_then_move", ABORT, nullptr);
393  if (!new_data)
394  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_then_move", ABORT,
395  "new_data is nullptr");
396  #endif
397 
398  new_element = new CLIST_LINK;
399  new_element->data = new_data;
400 
401  if (list->empty ()) {
402  new_element->next = new_element;
403  list->last = new_element;
404  prev = next = new_element;
405  }
406  else {
407  prev->next = new_element;
408  if (current) { //not extracted
409  new_element->next = current;
410  next = current;
411  }
412  else { //current extracted
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;
418  }
419  }
420  current = new_element;
421 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_list_after ( CLIST list_to_add)
inline

Definition at line 476 of file clst.h.

476  {
477  #ifndef NDEBUG
478  if (!list)
479  NO_LIST.error ("CLIST_ITERATOR::add_list_after", ABORT, nullptr);
480  if (!list_to_add)
481  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_after", ABORT,
482  "list_to_add is nullptr");
483  #endif
484 
485  if (!list_to_add->empty ()) {
486  if (list->empty ()) {
487  list->last = list_to_add->last;
488  prev = list->last;
489  next = list->First ();
490  ex_current_was_last = true;
491  current = nullptr;
492  }
493  else {
494  if (current) { //not extracted
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;
500  }
501  else { //current extracted
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;
506  }
507  list_to_add->last->next = next;
508  next = prev->next;
509  }
510  }
511  list_to_add->last = nullptr;
512  }
513 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_list_before ( CLIST list_to_add)
inline

Definition at line 523 of file clst.h.

523  {
524  #ifndef NDEBUG
525  if (!list)
526  NO_LIST.error ("CLIST_ITERATOR::add_list_before", ABORT, nullptr);
527  if (!list_to_add)
528  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_before", ABORT,
529  "list_to_add is nullptr");
530  #endif
531 
532  if (!list_to_add->empty ()) {
533  if (list->empty ()) {
534  list->last = list_to_add->last;
535  prev = list->last;
536  current = list->First ();
537  next = current->next;
538  ex_current_was_last = false;
539  }
540  else {
541  prev->next = list_to_add->First ();
542  if (current) { //not extracted
543  list_to_add->last->next = current;
544  }
545  else { //current extracted
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;
551  }
552  current = prev->next;
553  next = current->next;
554  }
555  list_to_add->last = nullptr;
556  }
557 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::add_to_end ( void *  new_data)
inline

Definition at line 745 of file clst.h.

746  {
747  CLIST_LINK *new_element;
748 
749  #ifndef NDEBUG
750  if (!list)
751  NO_LIST.error ("CLIST_ITERATOR::add_to_end", ABORT, nullptr);
752  if (!new_data)
753  BAD_PARAMETER.error ("CLIST_ITERATOR::add_to_end", ABORT,
754  "new_data is nullptr");
755  #endif
756 
757  if (this->at_last ()) {
758  this->add_after_stay_put (new_data);
759  }
760  else {
761  if (this->at_first ()) {
762  this->add_before_stay_put (new_data);
763  list->last = prev;
764  }
765  else { //Iteratr is elsewhere
766  new_element = new CLIST_LINK;
767  new_element->data = new_data;
768 
769  new_element->next = list->last->next;
770  list->last->next = new_element;
771  list->last = new_element;
772  }
773  }
774 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool at_first()
Definition: clst.h:651
void add_after_stay_put(void *new_data)
Definition: clst.h:336
void add_before_stay_put(void *new_data)
Definition: clst.h:430
bool at_last()
Definition: clst.h:670
bool CLIST_ITERATOR::at_first ( )
inline

Definition at line 651 of file clst.h.

651  {
652  #ifndef NDEBUG
653  if (!list)
654  NO_LIST.error ("CLIST_ITERATOR::at_first", ABORT, nullptr);
655  #endif
656 
657  //we're at a deleted
658  return ((list->empty ()) || (current == list->First ()) || ((current == nullptr) &&
659  (prev == list->last) && //NON-last pt between
660  !ex_current_was_last)); //first and last
661 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
bool CLIST_ITERATOR::at_last ( )
inline

Definition at line 670 of file clst.h.

670  {
671  #ifndef NDEBUG
672  if (!list)
673  NO_LIST.error ("CLIST_ITERATOR::at_last", ABORT, nullptr);
674  #endif
675 
676  //we're at a deleted
677  return ((list->empty ()) || (current == list->last) || ((current == nullptr) &&
678  (prev == list->last) && //last point between
679  ex_current_was_last)); //first and last
680 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
bool CLIST_ITERATOR::current_extracted ( )
inline

Definition at line 223 of file clst.h.

223  { //current extracted?
224  return !current;
225  }
bool CLIST_ITERATOR::cycled_list ( )
inline

Definition at line 689 of file clst.h.

689  {
690  #ifndef NDEBUG
691  if (!list)
692  NO_LIST.error ("CLIST_ITERATOR::cycled_list", ABORT, nullptr);
693  #endif
694 
695  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
696 
697 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void* CLIST_ITERATOR::data ( )
inline

Definition at line 192 of file clst.h.

192  { //get current data
193  #ifndef NDEBUG
194  if (!list)
195  NO_LIST.error ("CLIST_ITERATOR::data", ABORT, nullptr);
196  if (!current)
197  NULL_DATA.error ("CLIST_ITERATOR::data", ABORT, nullptr);
198  #endif
199  return current->data;
200  }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void * CLIST_ITERATOR::data_relative ( int8_t  offset)

Definition at line 284 of file clst.cpp.

285  { //offset from current
286  CLIST_LINK *ptr;
287 
288  #ifndef NDEBUG
289  if (!list)
290  NO_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
291  if (list->empty ())
292  EMPTY_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
293  if (offset < -1)
294  BAD_PARAMETER.error ("CLIST_ITERATOR::data_relative", ABORT,
295  "offset < -l");
296  #endif
297 
298  if (offset == -1)
299  ptr = prev;
300  else
301  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
302 
303  #ifndef NDEBUG
304  if (!ptr)
305  NULL_DATA.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
306  #endif
307 
308  return ptr->data;
309 }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE EMPTY_LIST("List is empty")
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
bool CLIST_ITERATOR::empty ( )
inline

Definition at line 215 of file clst.h.

215  { //is list empty?
216  #ifndef NDEBUG
217  if (!list)
218  NO_LIST.error ("CLIST_ITERATOR::empty", ABORT, nullptr);
219  #endif
220  return list->empty ();
221  }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void CLIST_ITERATOR::exchange ( CLIST_ITERATOR other_it)

Definition at line 344 of file clst.cpp.

345  { //other iterator
346  constexpr ERRCODE DONT_EXCHANGE_DELETED(
347  "Can't exchange deleted elements of lists");
348 
349  CLIST_LINK *old_current;
350 
351  #ifndef NDEBUG
352  if (!list)
353  NO_LIST.error ("CLIST_ITERATOR::exchange", ABORT, nullptr);
354  if (!other_it)
355  BAD_PARAMETER.error ("CLIST_ITERATOR::exchange", ABORT, "other_it nullptr");
356  if (!(other_it->list))
357  NO_LIST.error ("CLIST_ITERATOR::exchange", ABORT, "other_it");
358  #endif
359 
360  /* Do nothing if either list is empty or if both iterators reference the same
361  link */
362 
363  if ((list->empty ()) ||
364  (other_it->list->empty ()) || (current == other_it->current))
365  return;
366 
367  /* Error if either current element is deleted */
368 
369  if (!current || !other_it->current)
370  DONT_EXCHANGE_DELETED.error ("CLIST_ITERATOR.exchange", ABORT, nullptr);
371 
372  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
373  (other before this); non-doubleton adjacent elements (this before other);
374  non-adjacent elements. */
375 
376  //adjacent links
377  if ((next == other_it->current) ||
378  (other_it->next == current)) {
379  //doubleton list
380  if ((next == other_it->current) &&
381  (other_it->next == current)) {
382  prev = next = current;
383  other_it->prev = other_it->next = other_it->current;
384  }
385  else { //non-doubleton with
386  //adjacent links
387  //other before this
388  if (other_it->next == current) {
389  other_it->prev->next = current;
390  other_it->current->next = next;
391  current->next = other_it->current;
392  other_it->next = other_it->current;
393  prev = current;
394  }
395  else { //this before other
396  prev->next = other_it->current;
397  current->next = other_it->next;
398  other_it->current->next = current;
399  next = current;
400  other_it->prev = other_it->current;
401  }
402  }
403  }
404  else { //no overlap
405  prev->next = other_it->current;
406  current->next = other_it->next;
407  other_it->prev->next = current;
408  other_it->current->next = next;
409  }
410 
411  /* update end of list pointer when necessary (remember that the 2 iterators
412  may iterate over different lists!) */
413 
414  if (list->last == current)
415  list->last = other_it->current;
416  if (other_it->list->last == other_it->current)
417  other_it->list->last = current;
418 
419  if (current == cycle_pt)
420  cycle_pt = other_it->cycle_pt;
421  if (other_it->current == other_it->cycle_pt)
422  other_it->cycle_pt = cycle_pt;
423 
424  /* The actual exchange - in all cases*/
425 
426  old_current = current;
427  current = other_it->current;
428  other_it->current = old_current;
429 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: clst.h:93
void * CLIST_ITERATOR::extract ( )
inline

Definition at line 568 of file clst.h.

568  {
569  void *extracted_data;
570 
571  #ifndef NDEBUG
572  if (!list)
573  NO_LIST.error ("CLIST_ITERATOR::extract", ABORT, nullptr);
574  if (!current) //list empty or
575  //element extracted
576  NULL_CURRENT.error ("CLIST_ITERATOR::extract",
577  ABORT, nullptr);
578  #endif
579 
580  if (list->singleton()) {
581  // Special case where we do need to change the iterator.
582  prev = next = list->last = nullptr;
583  } else {
584  prev->next = next; //remove from list
585 
586  if (current == list->last) {
587  list->last = prev;
588  ex_current_was_last = true;
589  } else {
590  ex_current_was_last = false;
591  }
592  }
593  // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
594  ex_current_was_cycle_pt = (current == cycle_pt);
595  extracted_data = current->data;
596  delete(current); //destroy CONS cell
597  current = nullptr;
598  return extracted_data;
599 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
bool singleton() const
Definition: clst.h:97
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
void * CLIST_ITERATOR::forward ( )

Definition at line 244 of file clst.cpp.

244  {
245  #ifndef NDEBUG
246  if (!list)
247  NO_LIST.error ("CLIST_ITERATOR::forward", ABORT, nullptr);
248  #endif
249  if (list->empty ())
250  return nullptr;
251 
252  if (current) { //not removed so
253  //set previous
254  prev = current;
255  started_cycling = true;
256  // In case next is deleted by another iterator, get next from current.
257  current = current->next;
258  } else {
259  if (ex_current_was_cycle_pt)
260  cycle_pt = next;
261  current = next;
262  }
263 
264  #ifndef NDEBUG
265  if (!current)
266  NULL_DATA.error ("CLIST_ITERATOR::forward", ABORT, nullptr);
267  if (!next)
268  NULL_NEXT.error ("CLIST_ITERATOR::forward", ABORT,
269  "This is: %p Current is: %p", this, current);
270  #endif
271 
272  next = current->next;
273  return current->data;
274 }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_NEXT("Next element on the list is nullptr")
bool empty() const
Definition: clst.h:93
int32_t CLIST_ITERATOR::length ( )
inline

Definition at line 706 of file clst.h.

706  {
707  #ifndef NDEBUG
708  if (!list)
709  NO_LIST.error ("CLIST_ITERATOR::length", ABORT, nullptr);
710  #endif
711 
712  return list->length ();
713 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
int32_t length() const
Definition: clst.cpp:114
void CLIST_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 631 of file clst.h.

631  {
632  #ifndef NDEBUG
633  if (!list)
634  NO_LIST.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, nullptr);
635  #endif
636 
637  if (current)
638  cycle_pt = current;
639  else
640  ex_current_was_cycle_pt = true;
641  started_cycling = false;
642 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void * CLIST_ITERATOR::move_to_first ( )
inline

Definition at line 608 of file clst.h.

608  {
609  #ifndef NDEBUG
610  if (!list)
611  NO_LIST.error ("CLIST_ITERATOR::move_to_first", ABORT, nullptr);
612  #endif
613 
614  current = list->First ();
615  prev = list->last;
616  next = current != nullptr ? current->next : nullptr;
617  return current != nullptr ? current->data : nullptr;
618 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void * CLIST_ITERATOR::move_to_last ( )

Definition at line 319 of file clst.cpp.

319  {
320  #ifndef NDEBUG
321  if (!list)
322  NO_LIST.error ("CLIST_ITERATOR::move_to_last", ABORT, nullptr);
323  #endif
324 
325  while (current != list->last)
326  forward();
327 
328  if (current == nullptr)
329  return nullptr;
330  else
331  return current->data;
332 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
void * forward()
Definition: clst.cpp:244
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void CLIST_ITERATOR::set_to_list ( CLIST list_to_iterate)
inline

Definition at line 254 of file clst.h.

255  {
256  #ifndef NDEBUG
257  if (!list_to_iterate)
258  BAD_PARAMETER.error ("CLIST_ITERATOR::set_to_list", ABORT,
259  "list_to_iterate is nullptr");
260  #endif
261 
262  list = list_to_iterate;
263  prev = list->last;
264  current = list->First ();
265  next = current != nullptr ? current->next : nullptr;
266  cycle_pt = nullptr; //await explicit set
267  started_cycling = false;
268  ex_current_was_last = false;
269  ex_current_was_cycle_pt = false;
270 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
void CLIST_ITERATOR::sort ( int   comparator const void *, const void *)
inline

Definition at line 723 of file clst.h.

725  {
726  #ifndef NDEBUG
727  if (!list)
728  NO_LIST.error ("CLIST_ITERATOR::sort", ABORT, nullptr);
729  #endif
730 
731  list->sort (comparator);
732  move_to_first();
733 }
void * move_to_first()
Definition: clst.h:608
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
void sort(int comparator( const void *, const void *))
Definition: clst.cpp:130
constexpr ERRCODE NO_LIST("Iterator not set to a list")

Friends And Related Function Documentation


The documentation for this class was generated from the following files: