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

Constructor & Destructor Documentation

CLIST_ITERATOR::CLIST_ITERATOR ( )
inline

Definition at line 165 of file clst.h.

165  { //constructor
166  list = NULL;
167  } //unassigned list
#define NULL
Definition: host.h:144
CLIST_ITERATOR::CLIST_ITERATOR ( CLIST list_to_iterate)
inline

Definition at line 282 of file clst.h.

282  {
283  set_to_list(list_to_iterate);
284 }
void set_to_list(CLIST *list_to_iterate)
Definition: clst.h:255

Member Function Documentation

void CLIST_ITERATOR::add_after_stay_put ( void *  new_data)
inline

Definition at line 344 of file clst.h.

345  {
346  CLIST_LINK *new_element;
347 
348  #ifndef NDEBUG
349  if (!this)
350  NULL_OBJECT.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, NULL);
351  if (!list)
352  NO_LIST.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, NULL);
353  if (!new_data)
354  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_stay_put", ABORT,
355  "new_data is NULL");
356  #endif
357 
358  new_element = new CLIST_LINK;
359  new_element->data = new_data;
360 
361  if (list->empty ()) {
362  new_element->next = new_element;
363  list->last = new_element;
364  prev = next = new_element;
365  ex_current_was_last = FALSE;
366  current = NULL;
367  }
368  else {
369  new_element->next = next;
370 
371  if (current) { //not extracted
372  current->next = new_element;
373  if (prev == current)
374  prev = new_element;
375  if (current == list->last)
376  list->last = new_element;
377  }
378  else { //current extracted
379  prev->next = new_element;
380  if (ex_current_was_last) {
381  list->last = new_element;
382  ex_current_was_last = FALSE;
383  }
384  }
385  next = new_element;
386  }
387 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define FALSE
Definition: capi.h:29
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void CLIST_ITERATOR::add_after_then_move ( void *  new_data)
inline

Definition at line 294 of file clst.h.

295  {
296  CLIST_LINK *new_element;
297 
298  #ifndef NDEBUG
299  if (!this)
300  NULL_OBJECT.error ("CLIST_ITERATOR::add_after_then_move", ABORT, NULL);
301  if (!list)
302  NO_LIST.error ("CLIST_ITERATOR::add_after_then_move", ABORT, NULL);
303  if (!new_data)
304  BAD_PARAMETER.error ("CLIST_ITERATOR::add_after_then_move", ABORT,
305  "new_data is NULL");
306  #endif
307 
308  new_element = new CLIST_LINK;
309  new_element->data = new_data;
310 
311  if (list->empty ()) {
312  new_element->next = new_element;
313  list->last = new_element;
314  prev = next = new_element;
315  }
316  else {
317  new_element->next = next;
318 
319  if (current) { //not extracted
320  current->next = new_element;
321  prev = current;
322  if (current == list->last)
323  list->last = new_element;
324  }
325  else { //current extracted
326  prev->next = new_element;
327  if (ex_current_was_last)
328  list->last = new_element;
329  if (ex_current_was_cycle_pt)
330  cycle_pt = new_element;
331  }
332  }
333  current = new_element;
334 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void CLIST_ITERATOR::add_before_stay_put ( void *  new_data)
inline

Definition at line 444 of file clst.h.

445  {
446  CLIST_LINK *new_element;
447 
448  #ifndef NDEBUG
449  if (!this)
450  NULL_OBJECT.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, NULL);
451  if (!list)
452  NO_LIST.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, NULL);
453  if (!new_data)
454  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_stay_put", ABORT,
455  "new_data is NULL");
456  #endif
457 
458  new_element = new CLIST_LINK;
459  new_element->data = new_data;
460 
461  if (list->empty ()) {
462  new_element->next = new_element;
463  list->last = new_element;
464  prev = next = new_element;
465  ex_current_was_last = TRUE;
466  current = NULL;
467  }
468  else {
469  prev->next = new_element;
470  if (current) { //not extracted
471  new_element->next = current;
472  if (next == current)
473  next = new_element;
474  }
475  else { //current extracted
476  new_element->next = next;
477  if (ex_current_was_last)
478  list->last = new_element;
479  }
480  prev = new_element;
481  }
482 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define TRUE
Definition: capi.h:28
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void CLIST_ITERATOR::add_before_then_move ( void *  new_data)
inline

Definition at line 397 of file clst.h.

398  {
399  CLIST_LINK *new_element;
400 
401  #ifndef NDEBUG
402  if (!this)
403  NULL_OBJECT.error ("CLIST_ITERATOR::add_before_then_move", ABORT, NULL);
404  if (!list)
405  NO_LIST.error ("CLIST_ITERATOR::add_before_then_move", ABORT, NULL);
406  if (!new_data)
407  BAD_PARAMETER.error ("CLIST_ITERATOR::add_before_then_move", ABORT,
408  "new_data is NULL");
409  #endif
410 
411  new_element = new CLIST_LINK;
412  new_element->data = new_data;
413 
414  if (list->empty ()) {
415  new_element->next = new_element;
416  list->last = new_element;
417  prev = next = new_element;
418  }
419  else {
420  prev->next = new_element;
421  if (current) { //not extracted
422  new_element->next = current;
423  next = current;
424  }
425  else { //current extracted
426  new_element->next = next;
427  if (ex_current_was_last)
428  list->last = new_element;
429  if (ex_current_was_cycle_pt)
430  cycle_pt = new_element;
431  }
432  }
433  current = new_element;
434 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void CLIST_ITERATOR::add_list_after ( CLIST list_to_add)
inline

Definition at line 492 of file clst.h.

492  {
493  #ifndef NDEBUG
494  if (!this)
495  NULL_OBJECT.error ("CLIST_ITERATOR::add_list_after", ABORT, NULL);
496  if (!list)
497  NO_LIST.error ("CLIST_ITERATOR::add_list_after", ABORT, NULL);
498  if (!list_to_add)
499  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_after", ABORT,
500  "list_to_add is NULL");
501  #endif
502 
503  if (!list_to_add->empty ()) {
504  if (list->empty ()) {
505  list->last = list_to_add->last;
506  prev = list->last;
507  next = list->First ();
508  ex_current_was_last = TRUE;
509  current = NULL;
510  }
511  else {
512  if (current) { //not extracted
513  current->next = list_to_add->First ();
514  if (current == list->last)
515  list->last = list_to_add->last;
516  list_to_add->last->next = next;
517  next = current->next;
518  }
519  else { //current extracted
520  prev->next = list_to_add->First ();
521  if (ex_current_was_last) {
522  list->last = list_to_add->last;
523  ex_current_was_last = FALSE;
524  }
525  list_to_add->last->next = next;
526  next = prev->next;
527  }
528  }
529  list_to_add->last = NULL;
530  }
531 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#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 CLIST_ITERATOR::add_list_before ( CLIST list_to_add)
inline

Definition at line 542 of file clst.h.

542  {
543  #ifndef NDEBUG
544  if (!this)
545  NULL_OBJECT.error ("CLIST_ITERATOR::add_list_before", ABORT, NULL);
546  if (!list)
547  NO_LIST.error ("CLIST_ITERATOR::add_list_before", ABORT, NULL);
548  if (!list_to_add)
549  BAD_PARAMETER.error ("CLIST_ITERATOR::add_list_before", ABORT,
550  "list_to_add is NULL");
551  #endif
552 
553  if (!list_to_add->empty ()) {
554  if (list->empty ()) {
555  list->last = list_to_add->last;
556  prev = list->last;
557  current = list->First ();
558  next = current->next;
559  ex_current_was_last = FALSE;
560  }
561  else {
562  prev->next = list_to_add->First ();
563  if (current) { //not extracted
564  list_to_add->last->next = current;
565  }
566  else { //current extracted
567  list_to_add->last->next = next;
568  if (ex_current_was_last)
569  list->last = list_to_add->last;
570  if (ex_current_was_cycle_pt)
571  cycle_pt = prev->next;
572  }
573  current = prev->next;
574  next = current->next;
575  }
576  list_to_add->last = NULL;
577  }
578 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define FALSE
Definition: capi.h:29
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void CLIST_ITERATOR::add_to_end ( void *  new_data)
inline

Definition at line 791 of file clst.h.

792  {
793  CLIST_LINK *new_element;
794 
795  #ifndef NDEBUG
796  if (!this)
797  NULL_OBJECT.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);
798  if (!list)
799  NO_LIST.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);
800  if (!new_data)
801  BAD_PARAMETER.error ("CLIST_ITERATOR::add_to_end", ABORT,
802  "new_data is NULL");
803  #endif
804 
805  if (this->at_last ()) {
806  this->add_after_stay_put (new_data);
807  }
808  else {
809  if (this->at_first ()) {
810  this->add_before_stay_put (new_data);
811  list->last = prev;
812  }
813  else { //Iteratr is elsewhere
814  new_element = new CLIST_LINK;
815  new_element->data = new_data;
816 
817  new_element->next = list->last->next;
818  list->last->next = new_element;
819  list->last = new_element;
820  }
821  }
822 }
void add_before_stay_put(void *new_data)
Definition: clst.h:444
Definition: errcode.h:30
void add_after_stay_put(void *new_data)
Definition: clst.h:344
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
BOOL8 at_last()
Definition: clst.h:704
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
BOOL8 at_first()
Definition: clst.h:682
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
BOOL8 CLIST_ITERATOR::at_first ( )
inline

Definition at line 682 of file clst.h.

682  {
683  #ifndef NDEBUG
684  if (!this)
685  NULL_OBJECT.error ("CLIST_ITERATOR::at_first", ABORT, NULL);
686  if (!list)
687  NO_LIST.error ("CLIST_ITERATOR::at_first", ABORT, NULL);
688  #endif
689 
690  //we're at a deleted
691  return ((list->empty ()) || (current == list->First ()) || ((current == NULL) &&
692  (prev == list->last) && //NON-last pt between
693  !ex_current_was_last)); //first and last
694 }
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
BOOL8 CLIST_ITERATOR::at_last ( )
inline

Definition at line 704 of file clst.h.

704  {
705  #ifndef NDEBUG
706  if (!this)
707  NULL_OBJECT.error ("CLIST_ITERATOR::at_last", ABORT, NULL);
708  if (!list)
709  NO_LIST.error ("CLIST_ITERATOR::at_last", ABORT, NULL);
710  #endif
711 
712  //we're at a deleted
713  return ((list->empty ()) || (current == list->last) || ((current == NULL) &&
714  (prev == list->last) && //last point between
715  ex_current_was_last)); //first and last
716 }
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
BOOL8 CLIST_ITERATOR::current_extracted ( )
inline

Definition at line 224 of file clst.h.

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

Definition at line 726 of file clst.h.

726  {
727  #ifndef NDEBUG
728  if (!this)
729  NULL_OBJECT.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);
730  if (!list)
731  NO_LIST.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);
732  #endif
733 
734  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
735 
736 }
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void* CLIST_ITERATOR::data ( )
inline

Definition at line 193 of file clst.h.

193  { //get current data
194  #ifndef NDEBUG
195  if (!list)
196  NO_LIST.error ("CLIST_ITERATOR::data", ABORT, NULL);
197  if (!current)
198  NULL_DATA.error ("CLIST_ITERATOR::data", ABORT, NULL);
199  #endif
200  return current->data;
201  }
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
void * CLIST_ITERATOR::data_relative ( inT8  offset)

Definition at line 315 of file clst.cpp.

316  { //offset from current
317  CLIST_LINK *ptr;
318 
319  #ifndef NDEBUG
320  if (!this)
321  NULL_OBJECT.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
322  if (!list)
323  NO_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
324  if (list->empty ())
325  EMPTY_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
326  if (offset < -1)
327  BAD_PARAMETER.error ("CLIST_ITERATOR::data_relative", ABORT,
328  "offset < -l");
329  #endif
330 
331  if (offset == -1)
332  ptr = prev;
333  else
334  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
335 
336  #ifndef NDEBUG
337  if (!ptr)
338  NULL_DATA.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
339  #endif
340 
341  return ptr->data;
342 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
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
BOOL8 CLIST_ITERATOR::empty ( )
inline

Definition at line 216 of file clst.h.

216  { //is list empty?
217  #ifndef NDEBUG
218  if (!list)
219  NO_LIST.error ("CLIST_ITERATOR::empty", ABORT, NULL);
220  #endif
221  return list->empty ();
222  }
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
void CLIST_ITERATOR::exchange ( CLIST_ITERATOR other_it)

Definition at line 381 of file clst.cpp.

382  { //other iterator
383  const ERRCODE DONT_EXCHANGE_DELETED =
384  "Can't exchange deleted elements of lists";
385 
386  CLIST_LINK *old_current;
387 
388  #ifndef NDEBUG
389  if (!this)
390  NULL_OBJECT.error ("CLIST_ITERATOR::exchange", ABORT, NULL);
391  if (!list)
392  NO_LIST.error ("CLIST_ITERATOR::exchange", ABORT, NULL);
393  if (!other_it)
394  BAD_PARAMETER.error ("CLIST_ITERATOR::exchange", ABORT, "other_it NULL");
395  if (!(other_it->list))
396  NO_LIST.error ("CLIST_ITERATOR::exchange", ABORT, "other_it");
397  #endif
398 
399  /* Do nothing if either list is empty or if both iterators reference the same
400  link */
401 
402  if ((list->empty ()) ||
403  (other_it->list->empty ()) || (current == other_it->current))
404  return;
405 
406  /* Error if either current element is deleted */
407 
408  if (!current || !other_it->current)
409  DONT_EXCHANGE_DELETED.error ("CLIST_ITERATOR.exchange", ABORT, NULL);
410 
411  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
412  (other before this); non-doubleton adjacent elements (this before other);
413  non-adjacent elements. */
414 
415  //adjacent links
416  if ((next == other_it->current) ||
417  (other_it->next == current)) {
418  //doubleton list
419  if ((next == other_it->current) &&
420  (other_it->next == current)) {
421  prev = next = current;
422  other_it->prev = other_it->next = other_it->current;
423  }
424  else { //non-doubleton with
425  //adjacent links
426  //other before this
427  if (other_it->next == current) {
428  other_it->prev->next = current;
429  other_it->current->next = next;
430  current->next = other_it->current;
431  other_it->next = other_it->current;
432  prev = current;
433  }
434  else { //this before other
435  prev->next = other_it->current;
436  current->next = other_it->next;
437  other_it->current->next = current;
438  next = current;
439  other_it->prev = other_it->current;
440  }
441  }
442  }
443  else { //no overlap
444  prev->next = other_it->current;
445  current->next = other_it->next;
446  other_it->prev->next = current;
447  other_it->current->next = next;
448  }
449 
450  /* update end of list pointer when necessary (remember that the 2 iterators
451  may iterate over different lists!) */
452 
453  if (list->last == current)
454  list->last = other_it->current;
455  if (other_it->list->last == other_it->current)
456  other_it->list->last = current;
457 
458  if (current == cycle_pt)
459  cycle_pt = other_it->cycle_pt;
460  if (other_it->current == other_it->cycle_pt)
461  other_it->cycle_pt = cycle_pt;
462 
463  /* The actual exchange - in all cases*/
464 
465  old_current = current;
466  current = other_it->current;
467  other_it->current = old_current;
468 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
#define NULL
Definition: host.h:144
const ERRCODE NULL_OBJECT
Definition: lsterr.h:33
void * CLIST_ITERATOR::extract ( )
inline

Definition at line 590 of file clst.h.

590  {
591  void *extracted_data;
592 
593  #ifndef NDEBUG
594  if (!this)
595  NULL_OBJECT.error ("CLIST_ITERATOR::extract", ABORT, NULL);
596  if (!list)
597  NO_LIST.error ("CLIST_ITERATOR::extract", ABORT, NULL);
598  if (!current) //list empty or
599  //element extracted
600  NULL_CURRENT.error ("CLIST_ITERATOR::extract",
601  ABORT, NULL);
602  #endif
603 
604  if (list->singleton()) {
605  // Special case where we do need to change the iterator.
606  prev = next = list->last = NULL;
607  } else {
608  prev->next = next; //remove from list
609 
610  if (current == list->last) {
611  list->last = prev;
612  ex_current_was_last = TRUE;
613  } else {
614  ex_current_was_last = FALSE;
615  }
616  }
617  // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
618  ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE;
619  extracted_data = current->data;
620  delete(current); //destroy CONS cell
621  current = NULL;
622  return extracted_data;
623 }
bool singleton() const
Definition: clst.h:99
Definition: errcode.h:30
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
void * CLIST_ITERATOR::forward ( )

Definition at line 273 of file clst.cpp.

273  {
274  #ifndef NDEBUG
275  if (!this)
276  NULL_OBJECT.error ("CLIST_ITERATOR::forward", ABORT, NULL);
277  if (!list)
278  NO_LIST.error ("CLIST_ITERATOR::forward", ABORT, NULL);
279  #endif
280  if (list->empty ())
281  return NULL;
282 
283  if (current) { //not removed so
284  //set previous
285  prev = current;
286  started_cycling = TRUE;
287  // In case next is deleted by another iterator, get next from current.
288  current = current->next;
289  } else {
290  if (ex_current_was_cycle_pt)
291  cycle_pt = next;
292  current = next;
293  }
294  next = current->next;
295 
296  #ifndef NDEBUG
297  if (!current)
298  NULL_DATA.error ("CLIST_ITERATOR::forward", ABORT, NULL);
299  if (!next)
300  NULL_NEXT.error ("CLIST_ITERATOR::forward", ABORT,
301  "This is: %p Current is: %p", this, current);
302  #endif
303  return current->data;
304 }
Definition: errcode.h:30
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
bool empty() const
Definition: clst.h:95
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 CLIST_ITERATOR::length ( )
inline

Definition at line 746 of file clst.h.

746  {
747  #ifndef NDEBUG
748  if (!this)
749  NULL_OBJECT.error ("CLIST_ITERATOR::length", ABORT, NULL);
750  if (!list)
751  NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL);
752  #endif
753 
754  return list->length ();
755 }
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
inT32 length() const
Definition: clst.cpp:132
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 CLIST_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 659 of file clst.h.

659  {
660  #ifndef NDEBUG
661  if (!this)
662  NULL_OBJECT.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
663  if (!list)
664  NO_LIST.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
665  #endif
666 
667  if (current)
668  cycle_pt = current;
669  else
670  ex_current_was_cycle_pt = TRUE;
671  started_cycling = FALSE;
672 }
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
void * CLIST_ITERATOR::move_to_first ( )
inline

Definition at line 633 of file clst.h.

633  {
634  #ifndef NDEBUG
635  if (!this)
636  NULL_OBJECT.error ("CLIST_ITERATOR::move_to_first", ABORT, NULL);
637  if (!list)
638  NO_LIST.error ("CLIST_ITERATOR::move_to_first", ABORT, NULL);
639  #endif
640 
641  current = list->First ();
642  prev = list->last;
643  next = current != NULL ? current->next : NULL;
644  return current != NULL ? current->data : NULL;
645 }
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
void * CLIST_ITERATOR::move_to_last ( )

Definition at line 353 of file clst.cpp.

353  {
354  #ifndef NDEBUG
355  if (!this)
356  NULL_OBJECT.error ("CLIST_ITERATOR::move_to_last", ABORT, NULL);
357  if (!list)
358  NO_LIST.error ("CLIST_ITERATOR::move_to_last", ABORT, NULL);
359  #endif
360 
361  while (current != list->last)
362  forward();
363 
364  if (current == NULL)
365  return NULL;
366  else
367  return current->data;
368 }
Definition: errcode.h:30
const ERRCODE NO_LIST
Definition: lsterr.h:32
void * forward()
Definition: clst.cpp:273
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 CLIST_ITERATOR::set_to_list ( CLIST list_to_iterate)
inline

Definition at line 255 of file clst.h.

256  {
257  #ifndef NDEBUG
258  if (!this)
259  NULL_OBJECT.error ("CLIST_ITERATOR::set_to_list", ABORT, NULL);
260  if (!list_to_iterate)
261  BAD_PARAMETER.error ("CLIST_ITERATOR::set_to_list", ABORT,
262  "list_to_iterate is NULL");
263  #endif
264 
265  list = list_to_iterate;
266  prev = list->last;
267  current = list->First ();
268  next = current != NULL ? current->next : NULL;
269  cycle_pt = NULL; //await explicit set
270  started_cycling = FALSE;
271  ex_current_was_last = FALSE;
272  ex_current_was_cycle_pt = FALSE;
273 }
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 CLIST_ITERATOR::sort ( int   comparatorconst void *, const void *)
inline

Definition at line 766 of file clst.h.

768  {
769  #ifndef NDEBUG
770  if (!this)
771  NULL_OBJECT.error ("CLIST_ITERATOR::sort", ABORT, NULL);
772  if (!list)
773  NO_LIST.error ("CLIST_ITERATOR::sort", ABORT, NULL);
774  #endif
775 
776  list->sort (comparator);
777  move_to_first();
778 }
void * move_to_first()
Definition: clst.h:633
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
void sort(int comparator(const void *, const void *))
Definition: clst.cpp:154
#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: