tesseract  3.04.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ELIST2_ITERATOR Class Reference

#include <elst2.h>

Public Member Functions

 ELIST2_ITERATOR ()
 
 ELIST2_ITERATOR (ELIST2 *list_to_iterate)
 
void set_to_list (ELIST2 *list_to_iterate)
 
void add_after_then_move (ELIST2_LINK *new_link)
 
void add_after_stay_put (ELIST2_LINK *new_link)
 
void add_before_then_move (ELIST2_LINK *new_link)
 
void add_before_stay_put (ELIST2_LINK *new_link)
 
void add_list_after (ELIST2 *list_to_add)
 
void add_list_before (ELIST2 *list_to_add)
 
ELIST2_LINKdata ()
 
ELIST2_LINKdata_relative (inT8 offset)
 
ELIST2_LINKforward ()
 
ELIST2_LINKbackward ()
 
ELIST2_LINKextract ()
 
ELIST2_LINKmove_to_first ()
 
ELIST2_LINKmove_to_last ()
 
void mark_cycle_pt ()
 
BOOL8 empty ()
 
BOOL8 current_extracted ()
 
BOOL8 at_first ()
 
BOOL8 at_last ()
 
BOOL8 cycled_list ()
 
void add_to_end (ELIST2_LINK *new_link)
 
void exchange (ELIST2_ITERATOR *other_it)
 
inT32 length ()
 
void sort (int comparator(const void *, const void *))
 

Friends

void ELIST2::assign_to_sublist (ELIST2_ITERATOR *, ELIST2_ITERATOR *)
 

Detailed Description

Definition at line 150 of file elst2.h.

Constructor & Destructor Documentation

ELIST2_ITERATOR::ELIST2_ITERATOR ( )
inline

Definition at line 171 of file elst2.h.

171  { //constructor
172  list = NULL;
173  } //unassigned list
ELIST2_ITERATOR::ELIST2_ITERATOR ( ELIST2 list_to_iterate)
inline

Definition at line 289 of file elst2.h.

289  {
290  set_to_list(list_to_iterate);
291 }
void set_to_list(ELIST2 *list_to_iterate)
Definition: elst2.h:264

Member Function Documentation

void ELIST2_ITERATOR::add_after_stay_put ( ELIST2_LINK new_link)
inline

Definition at line 350 of file elst2.h.

351  {
352  #ifndef NDEBUG
353  if (!list)
354  NO_LIST.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT, NULL);
355  if (!new_element)
356  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT,
357  "new_element is NULL");
358  if (new_element->next)
359  STILL_LINKED.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT, NULL);
360  #endif
361 
362  if (list->empty ()) {
363  new_element->next = new_element;
364  new_element->prev = new_element;
365  list->last = new_element;
366  prev = next = new_element;
367  ex_current_was_last = FALSE;
368  current = NULL;
369  }
370  else {
371  new_element->next = next;
372  next->prev = new_element;
373 
374  if (current) { //not extracted
375  new_element->prev = current;
376  current->next = new_element;
377  if (prev == current)
378  prev = new_element;
379  if (current == list->last)
380  list->last = new_element;
381  }
382  else { //current extracted
383  new_element->prev = prev;
384  prev->next = new_element;
385  if (ex_current_was_last) {
386  list->last = new_element;
387  ex_current_was_last = FALSE;
388  }
389  }
390  next = new_element;
391  }
392 }
bool empty() const
Definition: elst2.h:107
#define FALSE
Definition: capi.h:29
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
void ELIST2_ITERATOR::add_after_then_move ( ELIST2_LINK new_link)
inline

Definition at line 301 of file elst2.h.

302  {
303  #ifndef NDEBUG
304  if (!list)
305  NO_LIST.error ("ELIST2_ITERATOR::add_after_then_move", ABORT, NULL);
306  if (!new_element)
307  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_after_then_move", ABORT,
308  "new_element is NULL");
309  if (new_element->next)
310  STILL_LINKED.error ("ELIST2_ITERATOR::add_after_then_move", ABORT, NULL);
311  #endif
312 
313  if (list->empty ()) {
314  new_element->next = new_element;
315  new_element->prev = new_element;
316  list->last = new_element;
317  prev = next = new_element;
318  }
319  else {
320  new_element->next = next;
321  next->prev = new_element;
322 
323  if (current) { //not extracted
324  new_element->prev = current;
325  current->next = new_element;
326  prev = current;
327  if (current == list->last)
328  list->last = new_element;
329  }
330  else { //current extracted
331  new_element->prev = prev;
332  prev->next = new_element;
333  if (ex_current_was_last)
334  list->last = new_element;
335  if (ex_current_was_cycle_pt)
336  cycle_pt = new_element;
337  }
338  }
339  current = new_element;
340 }
bool empty() const
Definition: elst2.h:107
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
void ELIST2_ITERATOR::add_before_stay_put ( ELIST2_LINK new_link)
inline

Definition at line 449 of file elst2.h.

450  {
451  #ifndef NDEBUG
452  if (!list)
453  NO_LIST.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT, NULL);
454  if (!new_element)
455  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT,
456  "new_element is NULL");
457  if (new_element->next)
458  STILL_LINKED.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT, NULL);
459  #endif
460 
461  if (list->empty ()) {
462  new_element->next = new_element;
463  new_element->prev = new_element;
464  list->last = new_element;
465  prev = next = new_element;
466  ex_current_was_last = TRUE;
467  current = NULL;
468  }
469  else {
470  prev->next = new_element;
471  new_element->prev = prev;
472 
473  if (current) { //not extracted
474  new_element->next = current;
475  current->prev = new_element;
476  if (next == current)
477  next = new_element;
478  }
479  else { //current extracted
480  new_element->next = next;
481  next->prev = new_element;
482  if (ex_current_was_last)
483  list->last = new_element;
484  }
485  prev = new_element;
486  }
487 }
bool empty() const
Definition: elst2.h:107
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
void ELIST2_ITERATOR::add_before_then_move ( ELIST2_LINK new_link)
inline

Definition at line 402 of file elst2.h.

403  {
404  #ifndef NDEBUG
405  if (!list)
406  NO_LIST.error ("ELIST2_ITERATOR::add_before_then_move", ABORT, NULL);
407  if (!new_element)
408  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_before_then_move", ABORT,
409  "new_element is NULL");
410  if (new_element->next)
411  STILL_LINKED.error ("ELIST2_ITERATOR::add_before_then_move", ABORT, NULL);
412  #endif
413 
414  if (list->empty ()) {
415  new_element->next = new_element;
416  new_element->prev = new_element;
417  list->last = new_element;
418  prev = next = new_element;
419  }
420  else {
421  prev->next = new_element;
422  new_element->prev = prev;
423 
424  if (current) { //not extracted
425  new_element->next = current;
426  current->prev = new_element;
427  next = current;
428  }
429  else { //current extracted
430  new_element->next = next;
431  next->prev = new_element;
432  if (ex_current_was_last)
433  list->last = new_element;
434  if (ex_current_was_cycle_pt)
435  cycle_pt = new_element;
436  }
437  }
438  current = new_element;
439 }
bool empty() const
Definition: elst2.h:107
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
void ELIST2_ITERATOR::add_list_after ( ELIST2 list_to_add)
inline

Definition at line 497 of file elst2.h.

497  {
498  #ifndef NDEBUG
499  if (!list)
500  NO_LIST.error ("ELIST2_ITERATOR::add_list_after", ABORT, NULL);
501  if (!list_to_add)
502  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_list_after", ABORT,
503  "list_to_add is NULL");
504  #endif
505 
506  if (!list_to_add->empty ()) {
507  if (list->empty ()) {
508  list->last = list_to_add->last;
509  prev = list->last;
510  next = list->First ();
511  ex_current_was_last = TRUE;
512  current = NULL;
513  }
514  else {
515  if (current) { //not extracted
516  current->next = list_to_add->First ();
517  current->next->prev = current;
518  if (current == list->last)
519  list->last = list_to_add->last;
520  list_to_add->last->next = next;
521  next->prev = list_to_add->last;
522  next = current->next;
523  }
524  else { //current extracted
525  prev->next = list_to_add->First ();
526  prev->next->prev = prev;
527  if (ex_current_was_last) {
528  list->last = list_to_add->last;
529  ex_current_was_last = FALSE;
530  }
531  list_to_add->last->next = next;
532  next->prev = list_to_add->last;
533  next = prev->next;
534  }
535  }
536  list_to_add->last = NULL;
537  }
538 }
bool empty() const
Definition: elst2.h:107
#define FALSE
Definition: capi.h:29
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
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
void ELIST2_ITERATOR::add_list_before ( ELIST2 list_to_add)
inline

Definition at line 549 of file elst2.h.

549  {
550  #ifndef NDEBUG
551  if (!list)
552  NO_LIST.error ("ELIST2_ITERATOR::add_list_before", ABORT, NULL);
553  if (!list_to_add)
554  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_list_before", ABORT,
555  "list_to_add is NULL");
556  #endif
557 
558  if (!list_to_add->empty ()) {
559  if (list->empty ()) {
560  list->last = list_to_add->last;
561  prev = list->last;
562  current = list->First ();
563  next = current->next;
564  ex_current_was_last = FALSE;
565  }
566  else {
567  prev->next = list_to_add->First ();
568  prev->next->prev = prev;
569 
570  if (current) { //not extracted
571  list_to_add->last->next = current;
572  current->prev = list_to_add->last;
573  }
574  else { //current extracted
575  list_to_add->last->next = next;
576  next->prev = list_to_add->last;
577  if (ex_current_was_last)
578  list->last = list_to_add->last;
579  if (ex_current_was_cycle_pt)
580  cycle_pt = prev->next;
581  }
582  current = prev->next;
583  next = current->next;
584  }
585  list_to_add->last = NULL;
586  }
587 }
bool empty() const
Definition: elst2.h:107
#define FALSE
Definition: capi.h:29
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
Definition: errcode.h:30
void ELIST2_ITERATOR::add_to_end ( ELIST2_LINK new_link)
inline

Definition at line 806 of file elst2.h.

807  {
808  #ifndef NDEBUG
809  if (!list)
810  NO_LIST.error ("ELIST2_ITERATOR::add_to_end", ABORT, NULL);
811  if (!new_element)
812  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_to_end", ABORT,
813  "new_element is NULL");
814  if (new_element->next)
815  STILL_LINKED.error ("ELIST2_ITERATOR::add_to_end", ABORT, NULL);
816  #endif
817 
818  if (this->at_last ()) {
819  this->add_after_stay_put (new_element);
820  }
821  else {
822  if (this->at_first ()) {
823  this->add_before_stay_put (new_element);
824  list->last = new_element;
825  }
826  else { //Iteratr is elsewhere
827  new_element->next = list->last->next;
828  new_element->prev = list->last;
829  list->last->next->prev = new_element;
830  list->last->next = new_element;
831  list->last = new_element;
832  }
833  }
834 }
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
const ERRCODE NO_LIST
Definition: lsterr.h:32
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
void add_before_stay_put(ELIST2_LINK *new_link)
Definition: elst2.h:449
BOOL8 at_last()
Definition: elst2.h:727
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
BOOL8 at_first()
Definition: elst2.h:707
void add_after_stay_put(ELIST2_LINK *new_link)
Definition: elst2.h:350
BOOL8 ELIST2_ITERATOR::at_first ( )
inline

Definition at line 707 of file elst2.h.

707  {
708  #ifndef NDEBUG
709  if (!list)
710  NO_LIST.error ("ELIST2_ITERATOR::at_first", ABORT, NULL);
711  #endif
712 
713  //we're at a deleted
714  return ((list->empty ()) || (current == list->First ()) || ((current == NULL) &&
715  (prev == list->last) && //NON-last pt between
716  !ex_current_was_last)); //first and last
717 }
bool empty() const
Definition: elst2.h:107
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
BOOL8 ELIST2_ITERATOR::at_last ( )
inline

Definition at line 727 of file elst2.h.

727  {
728  #ifndef NDEBUG
729  if (!list)
730  NO_LIST.error ("ELIST2_ITERATOR::at_last", ABORT, NULL);
731  #endif
732 
733  //we're at a deleted
734  return ((list->empty ()) || (current == list->last) || ((current == NULL) &&
735  (prev == list->last) && //last point between
736  ex_current_was_last)); //first and last
737 }
bool empty() const
Definition: elst2.h:107
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
ELIST2_LINK * ELIST2_ITERATOR::backward ( )

Definition at line 229 of file elst2.cpp.

229  {
230  #ifndef NDEBUG
231  if (!list)
232  NO_LIST.error ("ELIST2_ITERATOR::backward", ABORT, NULL);
233  #endif
234  if (list->empty ())
235  return NULL;
236 
237  if (current) { //not removed so
238  //set previous
239  next = current;
240  started_cycling = TRUE;
241  // In case prev is deleted by another iterator, get it from current.
242  current = current->prev;
243  } else {
244  if (ex_current_was_cycle_pt)
245  cycle_pt = prev;
246  current = prev;
247  }
248  prev = current->prev;
249 
250  #ifndef NDEBUG
251  if (!current)
252  NULL_DATA.error ("ELIST2_ITERATOR::backward", ABORT, NULL);
253  if (!prev)
254  NULL_PREV.error ("ELIST2_ITERATOR::backward", ABORT,
255  "This is: %p Current is: %p", this, current);
256  #endif
257  return current;
258 }
const ERRCODE NULL_PREV
Definition: lsterr.h:37
bool empty() const
Definition: elst2.h:107
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
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
BOOL8 ELIST2_ITERATOR::current_extracted ( )
inline

Definition at line 233 of file elst2.h.

233  { //current extracted?
234  return !current;
235  }
BOOL8 ELIST2_ITERATOR::cycled_list ( )
inline

Definition at line 747 of file elst2.h.

747  {
748  #ifndef NDEBUG
749  if (!list)
750  NO_LIST.error ("ELIST2_ITERATOR::cycled_list", ABORT, NULL);
751  #endif
752 
753  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
754 
755 }
bool empty() const
Definition: elst2.h:107
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
ELIST2_LINK* ELIST2_ITERATOR::data ( )
inline

Definition at line 199 of file elst2.h.

199  { //get current data
200  #ifndef NDEBUG
201  if (!current)
202  NULL_DATA.error ("ELIST2_ITERATOR::data", ABORT, NULL);
203  if (!list)
204  NO_LIST.error ("ELIST2_ITERATOR::data", ABORT, NULL);
205  #endif
206  return current;
207  }
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
Definition: errcode.h:30
ELIST2_LINK * ELIST2_ITERATOR::data_relative ( inT8  offset)

Definition at line 268 of file elst2.cpp.

269  { //offset from current
270  ELIST2_LINK *ptr;
271 
272  #ifndef NDEBUG
273  if (!list)
274  NO_LIST.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);
275  if (list->empty ())
276  EMPTY_LIST.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);
277  #endif
278 
279  if (offset < 0)
280  for (ptr = current ? current : next; offset++ < 0; ptr = ptr->prev);
281  else
282  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
283 
284  #ifndef NDEBUG
285  if (!ptr)
286  NULL_DATA.error ("ELIST2_ITERATOR::data_relative", ABORT, NULL);
287  #endif
288 
289  return ptr;
290 }
const ERRCODE EMPTY_LIST
Definition: lsterr.h:38
bool empty() const
Definition: elst2.h:107
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
Definition: errcode.h:30
BOOL8 ELIST2_ITERATOR::empty ( )
inline

Definition at line 225 of file elst2.h.

225  { //is list empty?
226  #ifndef NDEBUG
227  if (!list)
228  NO_LIST.error ("ELIST2_ITERATOR::empty", ABORT, NULL);
229  #endif
230  return list->empty ();
231  }
bool empty() const
Definition: elst2.h:107
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
void ELIST2_ITERATOR::exchange ( ELIST2_ITERATOR other_it)

Definition at line 303 of file elst2.cpp.

304  { //other iterator
305  const ERRCODE DONT_EXCHANGE_DELETED =
306  "Can't exchange deleted elements of lists";
307 
308  ELIST2_LINK *old_current;
309 
310  #ifndef NDEBUG
311  if (!list)
312  NO_LIST.error ("ELIST2_ITERATOR::exchange", ABORT, NULL);
313  if (!other_it)
314  BAD_PARAMETER.error ("ELIST2_ITERATOR::exchange", ABORT, "other_it NULL");
315  if (!(other_it->list))
316  NO_LIST.error ("ELIST2_ITERATOR::exchange", ABORT, "other_it");
317  #endif
318 
319  /* Do nothing if either list is empty or if both iterators reference the same
320  link */
321 
322  if ((list->empty ()) ||
323  (other_it->list->empty ()) || (current == other_it->current))
324  return;
325 
326  /* Error if either current element is deleted */
327 
328  if (!current || !other_it->current)
329  DONT_EXCHANGE_DELETED.error ("ELIST2_ITERATOR.exchange", ABORT, NULL);
330 
331  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
332  (other before this); non-doubleton adjacent elements (this before other);
333  non-adjacent elements. */
334 
335  //adjacent links
336  if ((next == other_it->current) ||
337  (other_it->next == current)) {
338  //doubleton list
339  if ((next == other_it->current) &&
340  (other_it->next == current)) {
341  prev = next = current;
342  other_it->prev = other_it->next = other_it->current;
343  }
344  else { //non-doubleton with
345  //adjacent links
346  //other before this
347  if (other_it->next == current) {
348  other_it->prev->next = current;
349  other_it->current->next = next;
350  other_it->current->prev = current;
351  current->next = other_it->current;
352  current->prev = other_it->prev;
353  next->prev = other_it->current;
354 
355  other_it->next = other_it->current;
356  prev = current;
357  }
358  else { //this before other
359  prev->next = other_it->current;
360  current->next = other_it->next;
361  current->prev = other_it->current;
362  other_it->current->next = current;
363  other_it->current->prev = prev;
364  other_it->next->prev = current;
365 
366  next = current;
367  other_it->prev = other_it->current;
368  }
369  }
370  }
371  else { //no overlap
372  prev->next = other_it->current;
373  current->next = other_it->next;
374  current->prev = other_it->prev;
375  next->prev = other_it->current;
376  other_it->prev->next = current;
377  other_it->current->next = next;
378  other_it->current->prev = prev;
379  other_it->next->prev = current;
380  }
381 
382  /* update end of list pointer when necessary (remember that the 2 iterators
383  may iterate over different lists!) */
384 
385  if (list->last == current)
386  list->last = other_it->current;
387  if (other_it->list->last == other_it->current)
388  other_it->list->last = current;
389 
390  if (current == cycle_pt)
391  cycle_pt = other_it->cycle_pt;
392  if (other_it->current == other_it->cycle_pt)
393  other_it->cycle_pt = cycle_pt;
394 
395  /* The actual exchange - in all cases*/
396 
397  old_current = current;
398  current = other_it->current;
399  other_it->current = old_current;
400 }
bool empty() const
Definition: elst2.h:107
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
Definition: errcode.h:30
ELIST2_LINK * ELIST2_ITERATOR::extract ( )
inline

Definition at line 599 of file elst2.h.

599  {
600  ELIST2_LINK *extracted_link;
601 
602  #ifndef NDEBUG
603  if (!list)
604  NO_LIST.error ("ELIST2_ITERATOR::extract", ABORT, NULL);
605  if (!current) //list empty or
606  //element extracted
607  NULL_CURRENT.error ("ELIST2_ITERATOR::extract",
608  ABORT, NULL);
609  #endif
610 
611  if (list->singleton()) {
612  // Special case where we do need to change the iterator.
613  prev = next = list->last = NULL;
614  } else {
615  prev->next = next; //remove from list
616  next->prev = prev;
617 
618  if (current == list->last) {
619  list->last = prev;
620  ex_current_was_last = TRUE;
621  } else {
622  ex_current_was_last = FALSE;
623  }
624  }
625  // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
626  ex_current_was_cycle_pt = (current == cycle_pt) ? TRUE : FALSE;
627  extracted_link = current;
628  extracted_link->next = NULL; //for safety
629  extracted_link->prev = NULL; //for safety
630  current = NULL;
631  return extracted_link;
632 }
bool singleton() const
Definition: elst2.h:111
#define FALSE
Definition: capi.h:29
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
const ERRCODE NULL_CURRENT
Definition: lsterr.h:35
ELIST2_LINK * ELIST2_ITERATOR::forward ( )

Definition at line 189 of file elst2.cpp.

189  {
190  #ifndef NDEBUG
191  if (!list)
192  NO_LIST.error ("ELIST2_ITERATOR::forward", ABORT, NULL);
193  #endif
194  if (list->empty ())
195  return NULL;
196 
197  if (current) { //not removed so
198  //set previous
199  prev = current;
200  started_cycling = TRUE;
201  // In case next is deleted by another iterator, get it from the current.
202  current = current->next;
203  }
204  else {
205  if (ex_current_was_cycle_pt)
206  cycle_pt = next;
207  current = next;
208  }
209  next = current->next;
210 
211  #ifndef NDEBUG
212  if (!current)
213  NULL_DATA.error ("ELIST2_ITERATOR::forward", ABORT, NULL);
214  if (!next)
215  NULL_NEXT.error ("ELIST2_ITERATOR::forward", ABORT,
216  "This is: %p Current is: %p", this, current);
217  #endif
218  return current;
219 }
const ERRCODE NULL_NEXT
Definition: lsterr.h:36
bool empty() const
Definition: elst2.h:107
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
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
inT32 ELIST2_ITERATOR::length ( )
inline

Definition at line 765 of file elst2.h.

765  {
766  #ifndef NDEBUG
767  if (!list)
768  NO_LIST.error ("ELIST2_ITERATOR::length", ABORT, NULL);
769  #endif
770 
771  return list->length ();
772 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
inT32 length() const
Definition: elst2.cpp:92
void ELIST2_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 686 of file elst2.h.

686  {
687  #ifndef NDEBUG
688  if (!list)
689  NO_LIST.error ("ELIST2_ITERATOR::mark_cycle_pt", ABORT, NULL);
690  #endif
691 
692  if (current)
693  cycle_pt = current;
694  else
695  ex_current_was_cycle_pt = TRUE;
696  started_cycling = FALSE;
697 }
#define FALSE
Definition: capi.h:29
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
#define TRUE
Definition: capi.h:28
ELIST2_LINK * ELIST2_ITERATOR::move_to_first ( )
inline

Definition at line 642 of file elst2.h.

642  {
643  #ifndef NDEBUG
644  if (!list)
645  NO_LIST.error ("ELIST2_ITERATOR::move_to_first", ABORT, NULL);
646  #endif
647 
648  current = list->First ();
649  prev = list->last;
650  next = current ? current->next : NULL;
651  return current;
652 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
ELIST2_LINK * ELIST2_ITERATOR::move_to_last ( )
inline

Definition at line 662 of file elst2.h.

662  {
663  #ifndef NDEBUG
664  if (!list)
665  NO_LIST.error ("ELIST2_ITERATOR::move_to_last", ABORT, NULL);
666  #endif
667 
668  current = list->last;
669  prev = current ? current->prev : NULL;
670  next = current ? current->next : NULL;
671  return current;
672 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
void ELIST2_ITERATOR::set_to_list ( ELIST2 list_to_iterate)
inline

Definition at line 264 of file elst2.h.

265  {
266  #ifndef NDEBUG
267  if (!list_to_iterate)
268  BAD_PARAMETER.error ("ELIST2_ITERATOR::set_to_list", ABORT,
269  "list_to_iterate is NULL");
270  #endif
271 
272  list = list_to_iterate;
273  prev = list->last;
274  current = list->First ();
275  next = current ? current->next : NULL;
276  cycle_pt = NULL; //await explicit set
277  started_cycling = FALSE;
278  ex_current_was_last = FALSE;
279  ex_current_was_cycle_pt = FALSE;
280 }
#define FALSE
Definition: capi.h:29
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
void ELIST2_ITERATOR::sort ( int   comparatorconst void *, const void *)
inline

Definition at line 783 of file elst2.h.

785  {
786  #ifndef NDEBUG
787  if (!list)
788  NO_LIST.error ("ELIST2_ITERATOR::sort", ABORT, NULL);
789  #endif
790 
791  list->sort (comparator);
792  move_to_first();
793 }
void sort(int comparator(const void *, const void *))
Definition: elst2.cpp:111
const ERRCODE NO_LIST
Definition: lsterr.h:32
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
Definition: errcode.h:30
ELIST2_LINK * move_to_first()
Definition: elst2.h:642

Friends And Related Function Documentation


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