Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ELIST_ITERATOR Class Reference

#include <elst.h>

Public Member Functions

 ELIST_ITERATOR ()
 
 ELIST_ITERATOR (ELIST *list_to_iterate)
 
void set_to_list (ELIST *list_to_iterate)
 
void add_after_then_move (ELIST_LINK *new_link)
 
void add_after_stay_put (ELIST_LINK *new_link)
 
void add_before_then_move (ELIST_LINK *new_link)
 
void add_before_stay_put (ELIST_LINK *new_link)
 
void add_list_after (ELIST *list_to_add)
 
void add_list_before (ELIST *list_to_add)
 
ELIST_LINKdata ()
 
ELIST_LINKdata_relative (inT8 offset)
 
ELIST_LINKforward ()
 
ELIST_LINKextract ()
 
ELIST_LINKmove_to_first ()
 
ELIST_LINKmove_to_last ()
 
void mark_cycle_pt ()
 
bool empty ()
 
bool current_extracted ()
 
bool at_first ()
 
bool at_last ()
 
bool cycled_list ()
 
void add_to_end (ELIST_LINK *new_link)
 
void exchange (ELIST_ITERATOR *other_it)
 
inT32 length ()
 
void sort (int comparator(const void *, const void *))
 

Friends

void ELIST::assign_to_sublist (ELIST_ITERATOR *, ELIST_ITERATOR *)
 

Detailed Description

Definition at line 188 of file elst.h.

Constructor & Destructor Documentation

ELIST_ITERATOR::ELIST_ITERATOR ( )
inline

Definition at line 209 of file elst.h.

209  { //constructor
210  list = NULL;
211  } //unassigned list
#define NULL
Definition: host.h:144
ELIST_ITERATOR::ELIST_ITERATOR ( ELIST list_to_iterate)
inline

Definition at line 326 of file elst.h.

326  {
327  set_to_list(list_to_iterate);
328 }
void set_to_list(ELIST *list_to_iterate)
Definition: elst.h:299

Member Function Documentation

void ELIST_ITERATOR::add_after_stay_put ( ELIST_LINK new_link)
inline

Definition at line 385 of file elst.h.

386  {
387  #ifndef NDEBUG
388  if (!this)
389  NULL_OBJECT.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
390  if (!list)
391  NO_LIST.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
392  if (!new_element)
393  BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_stay_put", ABORT,
394  "new_element is NULL");
395  if (new_element->next)
396  STILL_LINKED.error ("ELIST_ITERATOR::add_after_stay_put", ABORT, NULL);
397  #endif
398 
399  if (list->empty ()) {
400  new_element->next = new_element;
401  list->last = new_element;
402  prev = next = new_element;
403  ex_current_was_last = FALSE;
404  current = NULL;
405  }
406  else {
407  new_element->next = next;
408 
409  if (current) { //not extracted
410  current->next = new_element;
411  if (prev == current)
412  prev = new_element;
413  if (current == list->last)
414  list->last = new_element;
415  }
416  else { //current extracted
417  prev->next = new_element;
418  if (ex_current_was_last) {
419  list->last = new_element;
420  ex_current_was_last = FALSE;
421  }
422  }
423  next = new_element;
424  }
425 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::add_after_then_move ( ELIST_LINK new_link)
inline

Definition at line 338 of file elst.h.

339  {
340  #ifndef NDEBUG
341  if (!this)
342  NULL_OBJECT.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
343  if (!list)
344  NO_LIST.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
345  if (!new_element)
346  BAD_PARAMETER.error ("ELIST_ITERATOR::add_after_then_move", ABORT,
347  "new_element is NULL");
348  if (new_element->next)
349  STILL_LINKED.error ("ELIST_ITERATOR::add_after_then_move", ABORT, NULL);
350  #endif
351 
352  if (list->empty ()) {
353  new_element->next = new_element;
354  list->last = new_element;
355  prev = next = new_element;
356  }
357  else {
358  new_element->next = next;
359 
360  if (current) { //not extracted
361  current->next = new_element;
362  prev = current;
363  if (current == list->last)
364  list->last = new_element;
365  }
366  else { //current extracted
367  prev->next = new_element;
368  if (ex_current_was_last)
369  list->last = new_element;
370  if (ex_current_was_cycle_pt)
371  cycle_pt = new_element;
372  }
373  }
374  current = new_element;
375 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::add_before_stay_put ( ELIST_LINK new_link)
inline

Definition at line 479 of file elst.h.

480  {
481  #ifndef NDEBUG
482  if (!this)
483  NULL_OBJECT.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
484  if (!list)
485  NO_LIST.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
486  if (!new_element)
487  BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_stay_put", ABORT,
488  "new_element is NULL");
489  if (new_element->next)
490  STILL_LINKED.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, NULL);
491  #endif
492 
493  if (list->empty ()) {
494  new_element->next = new_element;
495  list->last = new_element;
496  prev = next = new_element;
497  ex_current_was_last = TRUE;
498  current = NULL;
499  }
500  else {
501  prev->next = new_element;
502  if (current) { //not extracted
503  new_element->next = current;
504  if (next == current)
505  next = new_element;
506  }
507  else { //current extracted
508  new_element->next = next;
509  if (ex_current_was_last)
510  list->last = new_element;
511  }
512  prev = new_element;
513  }
514 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
#define TRUE
Definition: capi.h:27
void ELIST_ITERATOR::add_before_then_move ( ELIST_LINK new_link)
inline

Definition at line 435 of file elst.h.

436  {
437  #ifndef NDEBUG
438  if (!this)
439  NULL_OBJECT.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
440  if (!list)
441  NO_LIST.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
442  if (!new_element)
443  BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_then_move", ABORT,
444  "new_element is NULL");
445  if (new_element->next)
446  STILL_LINKED.error ("ELIST_ITERATOR::add_before_then_move", ABORT, NULL);
447  #endif
448 
449  if (list->empty ()) {
450  new_element->next = new_element;
451  list->last = new_element;
452  prev = next = new_element;
453  }
454  else {
455  prev->next = new_element;
456  if (current) { //not extracted
457  new_element->next = current;
458  next = current;
459  }
460  else { //current extracted
461  new_element->next = next;
462  if (ex_current_was_last)
463  list->last = new_element;
464  if (ex_current_was_cycle_pt)
465  cycle_pt = new_element;
466  }
467  }
468  current = new_element;
469 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::add_list_after ( ELIST list_to_add)
inline

Definition at line 524 of file elst.h.

524  {
525  #ifndef NDEBUG
526  if (!this)
527  NULL_OBJECT.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);
528  if (!list)
529  NO_LIST.error ("ELIST_ITERATOR::add_list_after", ABORT, NULL);
530  if (!list_to_add)
531  BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_after", ABORT,
532  "list_to_add is NULL");
533  #endif
534 
535  if (!list_to_add->empty ()) {
536  if (list->empty ()) {
537  list->last = list_to_add->last;
538  prev = list->last;
539  next = list->First ();
540  ex_current_was_last = TRUE;
541  current = NULL;
542  }
543  else {
544  if (current) { //not extracted
545  current->next = list_to_add->First ();
546  if (current == list->last)
547  list->last = list_to_add->last;
548  list_to_add->last->next = next;
549  next = current->next;
550  }
551  else { //current extracted
552  prev->next = list_to_add->First ();
553  if (ex_current_was_last) {
554  list->last = list_to_add->last;
555  ex_current_was_last = FALSE;
556  }
557  list_to_add->last->next = next;
558  next = prev->next;
559  }
560  }
561  list_to_add->last = NULL;
562  }
563 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
#define TRUE
Definition: capi.h:27
void ELIST_ITERATOR::add_list_before ( ELIST list_to_add)
inline

Definition at line 574 of file elst.h.

574  {
575  #ifndef NDEBUG
576  if (!this)
577  NULL_OBJECT.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL);
578  if (!list)
579  NO_LIST.error ("ELIST_ITERATOR::add_list_before", ABORT, NULL);
580  if (!list_to_add)
581  BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_before", ABORT,
582  "list_to_add is NULL");
583  #endif
584 
585  if (!list_to_add->empty ()) {
586  if (list->empty ()) {
587  list->last = list_to_add->last;
588  prev = list->last;
589  current = list->First ();
590  next = current->next;
591  ex_current_was_last = FALSE;
592  }
593  else {
594  prev->next = list_to_add->First ();
595  if (current) { //not extracted
596  list_to_add->last->next = current;
597  }
598  else { //current extracted
599  list_to_add->last->next = next;
600  if (ex_current_was_last)
601  list->last = list_to_add->last;
602  if (ex_current_was_cycle_pt)
603  cycle_pt = prev->next;
604  }
605  current = prev->next;
606  next = current->next;
607  }
608  list_to_add->last = NULL;
609  }
610 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::add_to_end ( ELIST_LINK new_link)
inline

Definition at line 823 of file elst.h.

824  {
825  #ifndef NDEBUG
826  if (!this)
827  NULL_OBJECT.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
828  if (!list)
829  NO_LIST.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
830  if (!new_element)
831  BAD_PARAMETER.error ("ELIST_ITERATOR::add_to_end", ABORT,
832  "new_element is NULL");
833  if (new_element->next)
834  STILL_LINKED.error ("ELIST_ITERATOR::add_to_end", ABORT, NULL);
835  #endif
836 
837  if (this->at_last ()) {
838  this->add_after_stay_put (new_element);
839  }
840  else {
841  if (this->at_first ()) {
842  this->add_before_stay_put (new_element);
843  list->last = new_element;
844  }
845  else { //Iteratr is elsewhere
846  new_element->next = list->last->next;
847  list->last->next = new_element;
848  list->last = new_element;
849  }
850  }
851 }
void add_after_stay_put(ELIST_LINK *new_link)
Definition: elst.h:385
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
#define NULL
Definition: host.h:144
void add_before_stay_put(ELIST_LINK *new_link)
Definition: elst.h:479
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
bool at_last()
Definition: elst.h:736
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
bool at_first()
Definition: elst.h:714
bool ELIST_ITERATOR::at_first ( )
inline

Definition at line 714 of file elst.h.

714  {
715  #ifndef NDEBUG
716  if (!this)
717  NULL_OBJECT.error ("ELIST_ITERATOR::at_first", ABORT, NULL);
718  if (!list)
719  NO_LIST.error ("ELIST_ITERATOR::at_first", ABORT, NULL);
720  #endif
721 
722  //we're at a deleted
723  return ((list->empty ()) || (current == list->First ()) || ((current == NULL) &&
724  (prev == list->last) && //NON-last pt between
725  !ex_current_was_last)); //first and last
726 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
bool ELIST_ITERATOR::at_last ( )
inline

Definition at line 736 of file elst.h.

736  {
737  #ifndef NDEBUG
738  if (!this)
739  NULL_OBJECT.error ("ELIST_ITERATOR::at_last", ABORT, NULL);
740  if (!list)
741  NO_LIST.error ("ELIST_ITERATOR::at_last", ABORT, NULL);
742  #endif
743 
744  //we're at a deleted
745  return ((list->empty ()) || (current == list->last) || ((current == NULL) &&
746  (prev == list->last) && //last point between
747  ex_current_was_last)); //first and last
748 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
bool ELIST_ITERATOR::current_extracted ( )
inline

Definition at line 268 of file elst.h.

268  { //current extracted?
269  return !current;
270  }
bool ELIST_ITERATOR::cycled_list ( )
inline

Definition at line 758 of file elst.h.

758  {
759  #ifndef NDEBUG
760  if (!this)
761  NULL_OBJECT.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL);
762  if (!list)
763  NO_LIST.error ("ELIST_ITERATOR::cycled_list", ABORT, NULL);
764  #endif
765 
766  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
767 
768 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
ELIST_LINK* ELIST_ITERATOR::data ( )
inline

Definition at line 237 of file elst.h.

237  { //get current data
238  #ifndef NDEBUG
239  if (!list)
240  NO_LIST.error ("ELIST_ITERATOR::data", ABORT, NULL);
241  if (!current)
242  NULL_DATA.error ("ELIST_ITERATOR::data", ABORT, NULL);
243  #endif
244  return current;
245  }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
ELIST_LINK * ELIST_ITERATOR::data_relative ( inT8  offset)

Definition at line 259 of file elst.cpp.

260  { //offset from current
261  ELIST_LINK *ptr;
262 
263  #ifndef NDEBUG
264  if (!this)
265  NULL_OBJECT.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
266  if (!list)
267  NO_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
268  if (list->empty ())
269  EMPTY_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
270  if (offset < -1)
271  BAD_PARAMETER.error ("ELIST_ITERATOR::data_relative", ABORT,
272  "offset < -l");
273  #endif
274 
275  if (offset == -1)
276  ptr = prev;
277  else
278  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
279 
280  #ifndef NDEBUG
281  if (!ptr)
282  NULL_DATA.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
283  #endif
284 
285  return ptr;
286 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE EMPTY_LIST
Definition: lsterr.h:38
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
bool ELIST_ITERATOR::empty ( )
inline

Definition at line 260 of file elst.h.

260  { //is list empty?
261  #ifndef NDEBUG
262  if (!list)
263  NO_LIST.error ("ELIST_ITERATOR::empty", ABORT, NULL);
264  #endif
265  return list->empty ();
266  }
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::exchange ( ELIST_ITERATOR other_it)

Definition at line 322 of file elst.cpp.

323  { //other iterator
324  const ERRCODE DONT_EXCHANGE_DELETED =
325  "Can't exchange deleted elements of lists";
326 
327  ELIST_LINK *old_current;
328 
329  #ifndef NDEBUG
330  if (!this)
331  NULL_OBJECT.error ("ELIST_ITERATOR::exchange", ABORT, NULL);
332  if (!list)
333  NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, NULL);
334  if (!other_it)
335  BAD_PARAMETER.error ("ELIST_ITERATOR::exchange", ABORT, "other_it NULL");
336  if (!(other_it->list))
337  NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, "other_it");
338  #endif
339 
340  /* Do nothing if either list is empty or if both iterators reference the same
341  link */
342 
343  if ((list->empty ()) ||
344  (other_it->list->empty ()) || (current == other_it->current))
345  return;
346 
347  /* Error if either current element is deleted */
348 
349  if (!current || !other_it->current)
350  DONT_EXCHANGE_DELETED.error ("ELIST_ITERATOR.exchange", ABORT, NULL);
351 
352  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
353  (other before this); non-doubleton adjacent elements (this before other);
354  non-adjacent elements. */
355 
356  //adjacent links
357  if ((next == other_it->current) ||
358  (other_it->next == current)) {
359  //doubleton list
360  if ((next == other_it->current) &&
361  (other_it->next == current)) {
362  prev = next = current;
363  other_it->prev = other_it->next = other_it->current;
364  }
365  else { //non-doubleton with
366  //adjacent links
367  //other before this
368  if (other_it->next == current) {
369  other_it->prev->next = current;
370  other_it->current->next = next;
371  current->next = other_it->current;
372  other_it->next = other_it->current;
373  prev = current;
374  }
375  else { //this before other
376  prev->next = other_it->current;
377  current->next = other_it->next;
378  other_it->current->next = current;
379  next = current;
380  other_it->prev = other_it->current;
381  }
382  }
383  }
384  else { //no overlap
385  prev->next = other_it->current;
386  current->next = other_it->next;
387  other_it->prev->next = current;
388  other_it->current->next = next;
389  }
390 
391  /* update end of list pointer when necessary (remember that the 2 iterators
392  may iterate over different lists!) */
393 
394  if (list->last == current)
395  list->last = other_it->current;
396  if (other_it->list->last == other_it->current)
397  other_it->list->last = current;
398 
399  if (current == cycle_pt)
400  cycle_pt = other_it->cycle_pt;
401  if (other_it->current == other_it->cycle_pt)
402  other_it->cycle_pt = cycle_pt;
403 
404  /* The actual exchange - in all cases*/
405 
406  old_current = current;
407  current = other_it->current;
408  other_it->current = old_current;
409 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
ELIST_LINK * ELIST_ITERATOR::extract ( )
inline

Definition at line 622 of file elst.h.

622  {
623  ELIST_LINK *extracted_link;
624 
625  #ifndef NDEBUG
626  if (!this)
627  NULL_OBJECT.error ("ELIST_ITERATOR::extract", ABORT, NULL);
628  if (!list)
629  NO_LIST.error ("ELIST_ITERATOR::extract", ABORT, NULL);
630  if (!current) //list empty or
631  //element extracted
632  NULL_CURRENT.error ("ELIST_ITERATOR::extract",
633  ABORT, NULL);
634  #endif
635 
636  if (list->singleton()) {
637  // Special case where we do need to change the iterator.
638  prev = next = list->last = NULL;
639  } else {
640  prev->next = next; //remove from list
641 
642  if (current == list->last) {
643  list->last = prev;
644  ex_current_was_last = TRUE;
645  } else {
646  ex_current_was_last = FALSE;
647  }
648  }
649  // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
650  ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE;
651  extracted_link = current;
652  extracted_link->next = NULL; //for safety
653  current = NULL;
654  return extracted_link;
655 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
bool singleton() const
Definition: elst.h:137
const ERRCODE NULL_CURRENT
Definition: lsterr.h:35
#define TRUE
Definition: capi.h:27
ELIST_LINK * ELIST_ITERATOR::forward ( )

Definition at line 217 of file elst.cpp.

217  {
218  #ifndef NDEBUG
219  if (!this)
220  NULL_OBJECT.error ("ELIST_ITERATOR::forward", ABORT, NULL);
221  if (!list)
222  NO_LIST.error ("ELIST_ITERATOR::forward", ABORT, NULL);
223  #endif
224  if (list->empty ())
225  return NULL;
226 
227  if (current) { //not removed so
228  //set previous
229  prev = current;
230  started_cycling = TRUE;
231  // In case next is deleted by another iterator, get next from current.
232  current = current->next;
233  } else {
234  if (ex_current_was_cycle_pt)
235  cycle_pt = next;
236  current = next;
237  }
238  next = current->next;
239 
240  #ifndef NDEBUG
241  if (!current)
242  NULL_DATA.error ("ELIST_ITERATOR::forward", ABORT, NULL);
243  if (!next)
244  NULL_NEXT.error ("ELIST_ITERATOR::forward", ABORT,
245  "This is: %p Current is: %p", this, current);
246  #endif
247  return current;
248 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
bool empty() const
Definition: elst.h:133
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
const ERRCODE NULL_NEXT
Definition: lsterr.h:36
#define TRUE
Definition: capi.h:27
inT32 ELIST_ITERATOR::length ( )
inline

Definition at line 778 of file elst.h.

778  {
779  #ifndef NDEBUG
780  if (!this)
781  NULL_OBJECT.error ("ELIST_ITERATOR::length", ABORT, NULL);
782  if (!list)
783  NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL);
784  #endif
785 
786  return list->length ();
787 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
inT32 length() const
Definition: elst.cpp:102
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 691 of file elst.h.

691  {
692  #ifndef NDEBUG
693  if (!this)
694  NULL_OBJECT.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
695  if (!list)
696  NO_LIST.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
697  #endif
698 
699  if (current)
700  cycle_pt = current;
701  else
702  ex_current_was_cycle_pt = TRUE;
703  started_cycling = FALSE;
704 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
#define TRUE
Definition: capi.h:27
ELIST_LINK * ELIST_ITERATOR::move_to_first ( )
inline

Definition at line 665 of file elst.h.

665  {
666  #ifndef NDEBUG
667  if (!this)
668  NULL_OBJECT.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL);
669  if (!list)
670  NO_LIST.error ("ELIST_ITERATOR::move_to_first", ABORT, NULL);
671  #endif
672 
673  current = list->First ();
674  prev = list->last;
675  next = current ? current->next : NULL;
676  return current;
677 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
ELIST_LINK * ELIST_ITERATOR::move_to_last ( )

Definition at line 297 of file elst.cpp.

297  {
298  #ifndef NDEBUG
299  if (!this)
300  NULL_OBJECT.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL);
301  if (!list)
302  NO_LIST.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL);
303  #endif
304 
305  while (current != list->last)
306  forward();
307 
308  return current;
309 }
ELIST_LINK * forward()
Definition: elst.cpp:217
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::set_to_list ( ELIST list_to_iterate)
inline

Definition at line 299 of file elst.h.

300  {
301  #ifndef NDEBUG
302  if (!this)
303  NULL_OBJECT.error ("ELIST_ITERATOR::set_to_list", ABORT, NULL);
304  if (!list_to_iterate)
305  BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT,
306  "list_to_iterate is NULL");
307  #endif
308 
309  list = list_to_iterate;
310  prev = list->last;
311  current = list->First ();
312  next = current ? current->next : NULL;
313  cycle_pt = NULL; //await explicit set
314  started_cycling = FALSE;
315  ex_current_was_last = FALSE;
316  ex_current_was_cycle_pt = FALSE;
317 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
Definition: errcode.h:30
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
void ELIST_ITERATOR::sort ( int   comparatorconst void *, const void *)
inline

Definition at line 798 of file elst.h.

800  {
801  #ifndef NDEBUG
802  if (!this)
803  NULL_OBJECT.error ("ELIST_ITERATOR::sort", ABORT, NULL);
804  if (!list)
805  NO_LIST.error ("ELIST_ITERATOR::sort", ABORT, NULL);
806  #endif
807 
808  list->sort (comparator);
809  move_to_first();
810 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
void sort(int comparator(const void *, const void *))
Definition: elst.cpp:126
Definition: errcode.h:30
#define NULL
Definition: host.h:144
ELIST_LINK * move_to_first()
Definition: elst.h:665
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41

Friends And Related Function Documentation


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