tesseract  4.0.0-1-g2a2b
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 145 of file clst.h.

Constructor & Destructor Documentation

◆ CLIST_ITERATOR() [1/2]

CLIST_ITERATOR::CLIST_ITERATOR ( )
inline

Definition at line 166 of file clst.h.

166  { //constructor
167  list = nullptr;
168  } //unassigned list

◆ CLIST_ITERATOR() [2/2]

CLIST_ITERATOR::CLIST_ITERATOR ( CLIST list_to_iterate)
inline

Definition at line 280 of file clst.h.

280  {
281  set_to_list(list_to_iterate);
282 }
void set_to_list(CLIST *list_to_iterate)
Definition: clst.h:256

Member Function Documentation

◆ add_after_stay_put()

void CLIST_ITERATOR::add_after_stay_put ( void *  new_data)
inline

Definition at line 338 of file clst.h.

339  {
340  CLIST_LINK *new_element;
341 
342  #ifndef NDEBUG
343  if (!list)
344  NO_LIST.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, nullptr);
345  if (!new_data)
346  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_stay_put", ABORT,
347  "new_data is nullptr");
348  #endif
349 
350  new_element = new CLIST_LINK;
351  new_element->data = new_data;
352 
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;
358  current = nullptr;
359  }
360  else {
361  new_element->next = next;
362 
363  if (current) { //not extracted
364  current->next = new_element;
365  if (prev == current)
366  prev = new_element;
367  if (current == list->last)
368  list->last = new_element;
369  }
370  else { //current extracted
371  prev->next = new_element;
372  if (ex_current_was_last) {
373  list->last = new_element;
374  ex_current_was_last = false;
375  }
376  }
377  next = new_element;
378  }
379 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_after_then_move()

void CLIST_ITERATOR::add_after_then_move ( void *  new_data)
inline

Definition at line 291 of file clst.h.

292  {
293  CLIST_LINK *new_element;
294 
295  #ifndef NDEBUG
296  if (!list)
297  NO_LIST.error ("CLIST_ITERATOR::add_after_then_move", ABORT, nullptr);
298  if (!new_data)
299  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_then_move", ABORT,
300  "new_data is nullptr");
301  #endif
302 
303  new_element = new CLIST_LINK;
304  new_element->data = new_data;
305 
306  if (list->empty ()) {
307  new_element->next = new_element;
308  list->last = new_element;
309  prev = next = new_element;
310  }
311  else {
312  new_element->next = next;
313 
314  if (current) { //not extracted
315  current->next = new_element;
316  prev = current;
317  if (current == list->last)
318  list->last = new_element;
319  }
320  else { //current extracted
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;
326  }
327  }
328  current = new_element;
329 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_before_stay_put()

void CLIST_ITERATOR::add_before_stay_put ( void *  new_data)
inline

Definition at line 432 of file clst.h.

433  {
434  CLIST_LINK *new_element;
435 
436  #ifndef NDEBUG
437  if (!list)
438  NO_LIST.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
439  if (!new_data)
440  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_stay_put", ABORT,
441  "new_data is nullptr");
442  #endif
443 
444  new_element = new CLIST_LINK;
445  new_element->data = new_data;
446 
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;
452  current = nullptr;
453  }
454  else {
455  prev->next = new_element;
456  if (current) { //not extracted
457  new_element->next = current;
458  if (next == current)
459  next = new_element;
460  }
461  else { //current extracted
462  new_element->next = next;
463  if (ex_current_was_last)
464  list->last = new_element;
465  }
466  prev = new_element;
467  }
468 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_before_then_move()

void CLIST_ITERATOR::add_before_then_move ( void *  new_data)
inline

Definition at line 388 of file clst.h.

389  {
390  CLIST_LINK *new_element;
391 
392  #ifndef NDEBUG
393  if (!list)
394  NO_LIST.error ("CLIST_ITERATOR::add_before_then_move", ABORT, nullptr);
395  if (!new_data)
396  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_then_move", ABORT,
397  "new_data is nullptr");
398  #endif
399 
400  new_element = new CLIST_LINK;
401  new_element->data = new_data;
402 
403  if (list->empty ()) {
404  new_element->next = new_element;
405  list->last = new_element;
406  prev = next = new_element;
407  }
408  else {
409  prev->next = new_element;
410  if (current) { //not extracted
411  new_element->next = current;
412  next = current;
413  }
414  else { //current extracted
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;
420  }
421  }
422  current = new_element;
423 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_list_after()

void CLIST_ITERATOR::add_list_after ( CLIST list_to_add)
inline

Definition at line 478 of file clst.h.

478  {
479  #ifndef NDEBUG
480  if (!list)
481  NO_LIST.error ("CLIST_ITERATOR::add_list_after", ABORT, nullptr);
482  if (!list_to_add)
483  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_after", ABORT,
484  "list_to_add is nullptr");
485  #endif
486 
487  if (!list_to_add->empty ()) {
488  if (list->empty ()) {
489  list->last = list_to_add->last;
490  prev = list->last;
491  next = list->First ();
492  ex_current_was_last = true;
493  current = nullptr;
494  }
495  else {
496  if (current) { //not extracted
497  current->next = list_to_add->First ();
498  if (current == list->last)
499  list->last = list_to_add->last;
500  list_to_add->last->next = next;
501  next = current->next;
502  }
503  else { //current extracted
504  prev->next = list_to_add->First ();
505  if (ex_current_was_last) {
506  list->last = list_to_add->last;
507  ex_current_was_last = false;
508  }
509  list_to_add->last->next = next;
510  next = prev->next;
511  }
512  }
513  list_to_add->last = nullptr;
514  }
515 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_list_before()

void CLIST_ITERATOR::add_list_before ( CLIST list_to_add)
inline

Definition at line 525 of file clst.h.

525  {
526  #ifndef NDEBUG
527  if (!list)
528  NO_LIST.error ("CLIST_ITERATOR::add_list_before", ABORT, nullptr);
529  if (!list_to_add)
530  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_before", ABORT,
531  "list_to_add is nullptr");
532  #endif
533 
534  if (!list_to_add->empty ()) {
535  if (list->empty ()) {
536  list->last = list_to_add->last;
537  prev = list->last;
538  current = list->First ();
539  next = current->next;
540  ex_current_was_last = false;
541  }
542  else {
543  prev->next = list_to_add->First ();
544  if (current) { //not extracted
545  list_to_add->last->next = current;
546  }
547  else { //current extracted
548  list_to_add->last->next = next;
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;
553  }
554  current = prev->next;
555  next = current->next;
556  }
557  list_to_add->last = nullptr;
558  }
559 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_to_end()

void CLIST_ITERATOR::add_to_end ( void *  new_data)
inline

Definition at line 747 of file clst.h.

748  {
749  CLIST_LINK *new_element;
750 
751  #ifndef NDEBUG
752  if (!list)
753  NO_LIST.error ("CLIST_ITERATOR::add_to_end", ABORT, nullptr);
754  if (!new_data)
755  BAD_PARAMETER.error ("CLIST_ITERATOR::add_to_end", ABORT,
756  "new_data is nullptr");
757  #endif
758 
759  if (this->at_last ()) {
760  this->add_after_stay_put (new_data);
761  }
762  else {
763  if (this->at_first ()) {
764  this->add_before_stay_put (new_data);
765  list->last = prev;
766  }
767  else { //Iteratr is elsewhere
768  new_element = new CLIST_LINK;
769  new_element->data = new_data;
770 
771  new_element->next = list->last->next;
772  list->last->next = new_element;
773  list->last = new_element;
774  }
775  }
776 }
bool at_last()
Definition: clst.h:672
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void add_after_stay_put(void *new_data)
Definition: clst.h:338
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
bool at_first()
Definition: clst.h:653
void add_before_stay_put(void *new_data)
Definition: clst.h:432
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ at_first()

bool CLIST_ITERATOR::at_first ( )
inline

Definition at line 653 of file clst.h.

653  {
654  #ifndef NDEBUG
655  if (!list)
656  NO_LIST.error ("CLIST_ITERATOR::at_first", ABORT, nullptr);
657  #endif
658 
659  //we're at a deleted
660  return ((list->empty ()) || (current == list->First ()) || ((current == nullptr) &&
661  (prev == list->last) && //NON-last pt between
662  !ex_current_was_last)); //first and last
663 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ at_last()

bool CLIST_ITERATOR::at_last ( )
inline

Definition at line 672 of file clst.h.

672  {
673  #ifndef NDEBUG
674  if (!list)
675  NO_LIST.error ("CLIST_ITERATOR::at_last", ABORT, nullptr);
676  #endif
677 
678  //we're at a deleted
679  return ((list->empty ()) || (current == list->last) || ((current == nullptr) &&
680  (prev == list->last) && //last point between
681  ex_current_was_last)); //first and last
682 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ current_extracted()

bool CLIST_ITERATOR::current_extracted ( )
inline

Definition at line 225 of file clst.h.

225  { //current extracted?
226  return !current;
227  }

◆ cycled_list()

bool CLIST_ITERATOR::cycled_list ( )
inline

Definition at line 691 of file clst.h.

691  {
692  #ifndef NDEBUG
693  if (!list)
694  NO_LIST.error ("CLIST_ITERATOR::cycled_list", ABORT, nullptr);
695  #endif
696 
697  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
698 
699 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ data()

void* CLIST_ITERATOR::data ( )
inline

Definition at line 194 of file clst.h.

194  { //get current data
195  #ifndef NDEBUG
196  if (!list)
197  NO_LIST.error ("CLIST_ITERATOR::data", ABORT, nullptr);
198  if (!current)
199  NULL_DATA.error ("CLIST_ITERATOR::data", ABORT, nullptr);
200  #endif
201  return current->data;
202  }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ data_relative()

void * CLIST_ITERATOR::data_relative ( int8_t  offset)

Definition at line 285 of file clst.cpp.

286  { //offset from current
287  CLIST_LINK *ptr;
288 
289  #ifndef NDEBUG
290  if (!list)
291  NO_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
292  if (list->empty ())
293  EMPTY_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
294  if (offset < -1)
295  BAD_PARAMETER.error ("CLIST_ITERATOR::data_relative", ABORT,
296  "offset < -l");
297  #endif
298 
299  if (offset == -1)
300  ptr = prev;
301  else
302  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
303 
304  #ifndef NDEBUG
305  if (!ptr)
306  NULL_DATA.error ("CLIST_ITERATOR::data_relative", ABORT, nullptr);
307  #endif
308 
309  return ptr->data;
310 }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_DATA
Definition: lsterr.h:34
const ERRCODE EMPTY_LIST
Definition: lsterr.h:38
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ empty()

bool CLIST_ITERATOR::empty ( )
inline

Definition at line 217 of file clst.h.

217  { //is list empty?
218  #ifndef NDEBUG
219  if (!list)
220  NO_LIST.error ("CLIST_ITERATOR::empty", ABORT, nullptr);
221  #endif
222  return list->empty ();
223  }
bool empty() const
Definition: clst.h:95
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ exchange()

void CLIST_ITERATOR::exchange ( CLIST_ITERATOR other_it)

Definition at line 345 of file clst.cpp.

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

◆ extract()

void * CLIST_ITERATOR::extract ( )
inline

Definition at line 570 of file clst.h.

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

◆ forward()

void * CLIST_ITERATOR::forward ( )

Definition at line 245 of file clst.cpp.

245  {
246  #ifndef NDEBUG
247  if (!list)
248  NO_LIST.error ("CLIST_ITERATOR::forward", ABORT, nullptr);
249  #endif
250  if (list->empty ())
251  return nullptr;
252 
253  if (current) { //not removed so
254  //set previous
255  prev = current;
256  started_cycling = TRUE;
257  // In case next is deleted by another iterator, get next from current.
258  current = current->next;
259  } else {
260  if (ex_current_was_cycle_pt)
261  cycle_pt = next;
262  current = next;
263  }
264 
265  #ifndef NDEBUG
266  if (!current)
267  NULL_DATA.error ("CLIST_ITERATOR::forward", ABORT, nullptr);
268  if (!next)
269  NULL_NEXT.error ("CLIST_ITERATOR::forward", ABORT,
270  "This is: %p Current is: %p", this, current);
271  #endif
272 
273  next = current->next;
274  return current->data;
275 }
bool empty() const
Definition: clst.h:95
#define TRUE
Definition: capi.h:51
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_NEXT
Definition: lsterr.h:36
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ length()

int32_t CLIST_ITERATOR::length ( )
inline

Definition at line 708 of file clst.h.

708  {
709  #ifndef NDEBUG
710  if (!list)
711  NO_LIST.error ("CLIST_ITERATOR::length", ABORT, nullptr);
712  #endif
713 
714  return list->length ();
715 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
int32_t length() const
Definition: clst.cpp:115
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ mark_cycle_pt()

void CLIST_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 633 of file clst.h.

633  {
634  #ifndef NDEBUG
635  if (!list)
636  NO_LIST.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, nullptr);
637  #endif
638 
639  if (current)
640  cycle_pt = current;
641  else
642  ex_current_was_cycle_pt = TRUE;
643  started_cycling = FALSE;
644 }
#define TRUE
Definition: capi.h:51
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define FALSE
Definition: capi.h:52
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ move_to_first()

void * CLIST_ITERATOR::move_to_first ( )
inline

Definition at line 610 of file clst.h.

610  {
611  #ifndef NDEBUG
612  if (!list)
613  NO_LIST.error ("CLIST_ITERATOR::move_to_first", ABORT, nullptr);
614  #endif
615 
616  current = list->First ();
617  prev = list->last;
618  next = current != nullptr ? current->next : nullptr;
619  return current != nullptr ? current->data : nullptr;
620 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ move_to_last()

void * CLIST_ITERATOR::move_to_last ( )

Definition at line 320 of file clst.cpp.

320  {
321  #ifndef NDEBUG
322  if (!list)
323  NO_LIST.error ("CLIST_ITERATOR::move_to_last", ABORT, nullptr);
324  #endif
325 
326  while (current != list->last)
327  forward();
328 
329  if (current == nullptr)
330  return nullptr;
331  else
332  return current->data;
333 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void * forward()
Definition: clst.cpp:245
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ set_to_list()

void CLIST_ITERATOR::set_to_list ( CLIST list_to_iterate)
inline

Definition at line 256 of file clst.h.

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

◆ sort()

void CLIST_ITERATOR::sort ( int   comparator const void *, const void *)
inline

Definition at line 725 of file clst.h.

727  {
728  #ifndef NDEBUG
729  if (!list)
730  NO_LIST.error ("CLIST_ITERATOR::sort", ABORT, nullptr);
731  #endif
732 
733  list->sort (comparator);
734  move_to_first();
735 }
void * move_to_first()
Definition: clst.h:610
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void sort(int comparator(const void *, const void *))
Definition: clst.cpp:131
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

Friends And Related Function Documentation

◆ CLIST::assign_to_sublist


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