All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 187 of file elst.h.

Constructor & Destructor Documentation

ELIST_ITERATOR::ELIST_ITERATOR ( )
inline

Definition at line 208 of file elst.h.

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

Definition at line 324 of file elst.h.

324  {
325  set_to_list(list_to_iterate);
326 }
void set_to_list(ELIST *list_to_iterate)
Definition: elst.h:297

Member Function Documentation

void ELIST_ITERATOR::add_after_stay_put ( ELIST_LINK new_link)
inline

Definition at line 383 of file elst.h.

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

Definition at line 336 of file elst.h.

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

Definition at line 477 of file elst.h.

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

Definition at line 433 of file elst.h.

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

Definition at line 522 of file elst.h.

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

Definition at line 572 of file elst.h.

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

Definition at line 821 of file elst.h.

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

Definition at line 712 of file elst.h.

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

Definition at line 734 of file elst.h.

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

Definition at line 266 of file elst.h.

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

Definition at line 756 of file elst.h.

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

Definition at line 235 of file elst.h.

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

Definition at line 258 of file elst.cpp.

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

Definition at line 258 of file elst.h.

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

Definition at line 321 of file elst.cpp.

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

Definition at line 620 of file elst.h.

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

Definition at line 216 of file elst.cpp.

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

Definition at line 776 of file elst.h.

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

Definition at line 689 of file elst.h.

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

Definition at line 663 of file elst.h.

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

Definition at line 296 of file elst.cpp.

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

Definition at line 297 of file elst.h.

298  {
299  #ifndef NDEBUG
300  if (!this)
301  NULL_OBJECT.error ("ELIST_ITERATOR::set_to_list", ABORT, NULL);
302  if (!list_to_iterate)
303  BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT,
304  "list_to_iterate is NULL");
305  #endif
306 
307  list = list_to_iterate;
308  prev = list->last;
309  current = list->First ();
310  next = current ? current->next : NULL;
311  cycle_pt = NULL; //await explicit set
312  started_cycling = FALSE;
313  ex_current_was_last = FALSE;
314  ex_current_was_cycle_pt = FALSE;
315 }
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:40
#define FALSE
Definition: capi.h:29
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void ELIST_ITERATOR::sort ( int   comparatorconst void *, const void *)
inline

Definition at line 796 of file elst.h.

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

Friends And Related Function Documentation


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