tesseract  4.00.00dev
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 offset)
 
void * forward ()
 
void * extract ()
 
void * move_to_first ()
 
void * move_to_last ()
 
void mark_cycle_pt ()
 
BOOL8 empty ()
 
BOOL8 current_extracted ()
 
BOOL8 at_first ()
 
BOOL8 at_last ()
 
BOOL8 cycled_list ()
 
void add_to_end (void *new_data)
 
void exchange (CLIST_ITERATOR *other_it)
 
inT32 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 = NULL;
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, NULL);
345  if (!new_data)
346  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_stay_put", ABORT,
347  "new_data is NULL");
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 = NULL;
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 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
298  if (!new_data)
299  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_then_move", ABORT,
300  "new_data is NULL");
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 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
439  if (!new_data)
440  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_stay_put", ABORT,
441  "new_data is NULL");
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 = NULL;
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 }
#define TRUE
Definition: capi.h:45
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
395  if (!new_data)
396  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_then_move", ABORT,
397  "new_data is NULL");
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 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
482  if (!list_to_add)
483  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_after", ABORT,
484  "list_to_add is NULL");
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 = NULL;
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 = NULL;
514  }
515 }
#define TRUE
Definition: capi.h:45
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
529  if (!list_to_add)
530  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_before", ABORT,
531  "list_to_add is NULL");
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 = NULL;
558  }
559 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
754  if (!new_data)
755  BAD_PARAMETER.error ("CLIST_ITERATOR::add_to_end", ABORT,
756  "new_data is NULL");
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 }
BOOL8 at_last()
Definition: clst.h:672
BOOL8 at_first()
Definition: clst.h:653
void add_before_stay_put(void *new_data)
Definition: clst.h:432
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
void add_after_stay_put(void *new_data)
Definition: clst.h:338
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ at_first()

BOOL8 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, NULL);
657  #endif
658 
659  //we're at a deleted
660  return ((list->empty ()) || (current == list->First ()) || ((current == NULL) &&
661  (prev == list->last) && //NON-last pt between
662  !ex_current_was_last)); //first and last
663 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ at_last()

BOOL8 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, NULL);
676  #endif
677 
678  //we're at a deleted
679  return ((list->empty ()) || (current == list->last) || ((current == NULL) &&
680  (prev == list->last) && //last point between
681  ex_current_was_last)); //first and last
682 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ current_extracted()

BOOL8 CLIST_ITERATOR::current_extracted ( )
inline

Definition at line 225 of file clst.h.

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

◆ cycled_list()

BOOL8 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, NULL);
695  #endif
696 
697  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
698 
699 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
198  if (!current)
199  NULL_DATA.error ("CLIST_ITERATOR::data", ABORT, NULL);
200  #endif
201  return current->data;
202  }
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ data_relative()

void * CLIST_ITERATOR::data_relative ( inT8  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, NULL);
291  if (list->empty ())
292  EMPTY_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
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, NULL);
306  #endif
307 
308  return ptr->data;
309 }
const ERRCODE NULL_DATA
Definition: lsterr.h:34
voidpf uLong offset
Definition: ioapi.h:42
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
const ERRCODE EMPTY_LIST
Definition: lsterr.h:38
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ empty()

BOOL8 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, NULL);
221  #endif
222  return list->empty ();
223  }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ exchange()

void CLIST_ITERATOR::exchange ( CLIST_ITERATOR other_it)

Definition at line 344 of file clst.cpp.

345  { //other iterator
346  const 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, NULL);
354  if (!other_it)
355  BAD_PARAMETER.error ("CLIST_ITERATOR::exchange", ABORT, "other_it NULL");
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, NULL);
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 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ 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, NULL);
576  if (!current) //list empty or
577  //element extracted
578  NULL_CURRENT.error ("CLIST_ITERATOR::extract",
579  ABORT, NULL);
580  #endif
581 
582  if (list->singleton()) {
583  // Special case where we do need to change the iterator.
584  prev = next = list->last = NULL;
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) ? TRUE : FALSE;
597  extracted_data = current->data;
598  delete(current); //destroy CONS cell
599  current = NULL;
600  return extracted_data;
601 }
#define TRUE
Definition: capi.h:45
bool singleton() const
Definition: clst.h:99
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE NULL_CURRENT
Definition: lsterr.h:35

◆ 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, NULL);
249  #endif
250  if (list->empty ())
251  return NULL;
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  next = current->next;
265 
266  #ifndef NDEBUG
267  if (!current)
268  NULL_DATA.error ("CLIST_ITERATOR::forward", ABORT, NULL);
269  if (!next)
270  NULL_NEXT.error ("CLIST_ITERATOR::forward", ABORT,
271  "This is: %p Current is: %p", this, current);
272  #endif
273  return current->data;
274 }
#define TRUE
Definition: capi.h:45
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:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: clst.h:95

◆ length()

inT32 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, NULL);
712  #endif
713 
714  return list->length ();
715 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
inT32 length() const
Definition: clst.cpp:115
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ 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, NULL);
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:45
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ 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, NULL);
614  #endif
615 
616  current = list->First ();
617  prev = list->last;
618  next = current != NULL ? current->next : NULL;
619  return current != NULL ? current->data : NULL;
620 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ move_to_last()

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, NULL);
323  #endif
324 
325  while (current != list->last)
326  forward();
327 
328  if (current == NULL)
329  return NULL;
330  else
331  return current->data;
332 }
void * forward()
Definition: clst.cpp:245
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32

◆ 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 NULL");
262  #endif
263 
264  list = list_to_iterate;
265  prev = list->last;
266  current = list->First ();
267  next = current != NULL ? current->next : NULL;
268  cycle_pt = NULL; //await explicit set
269  started_cycling = FALSE;
270  ex_current_was_last = FALSE;
271  ex_current_was_cycle_pt = FALSE;
272 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
#define FALSE
Definition: capi.h:46
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30

◆ 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, NULL);
731  #endif
732 
733  list->sort (comparator);
734  move_to_first();
735 }
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:40
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
void * move_to_first()
Definition: clst.h:610

Friends And Related Function Documentation

◆ CLIST::assign_to_sublist


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