tesseract  4.0.0-1-g2a2b
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_t 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_t 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() [1/2]

ELIST_ITERATOR::ELIST_ITERATOR ( )
inline

Definition at line 208 of file elst.h.

208  { //constructor
209  list = nullptr;
210  } //unassigned list

◆ ELIST_ITERATOR() [2/2]

ELIST_ITERATOR::ELIST_ITERATOR ( ELIST list_to_iterate)
inlineexplicit

Definition at line 322 of file elst.h.

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

Member Function Documentation

◆ add_after_stay_put()

void ELIST_ITERATOR::add_after_stay_put ( ELIST_LINK new_link)
inline

Definition at line 379 of file elst.h.

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

◆ add_after_then_move()

void ELIST_ITERATOR::add_after_then_move ( ELIST_LINK new_link)
inline

Definition at line 334 of file elst.h.

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

◆ add_before_stay_put()

void ELIST_ITERATOR::add_before_stay_put ( ELIST_LINK new_link)
inline

Definition at line 468 of file elst.h.

469  {
470  #ifndef NDEBUG
471  if (!list)
472  NO_LIST.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
473  if (!new_element)
474  BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_stay_put", ABORT,
475  "new_element is nullptr");
476  if (new_element->next)
477  STILL_LINKED.error ("ELIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
478  #endif
479 
480  if (list->empty ()) {
481  new_element->next = new_element;
482  list->last = new_element;
483  prev = next = new_element;
484  ex_current_was_last = TRUE;
485  current = nullptr;
486  }
487  else {
488  prev->next = new_element;
489  if (current) { //not extracted
490  new_element->next = current;
491  if (next == current)
492  next = new_element;
493  }
494  else { //current extracted
495  new_element->next = next;
496  if (ex_current_was_last)
497  list->last = new_element;
498  }
499  prev = new_element;
500  }
501 }
#define TRUE
Definition: capi.h:51
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_before_then_move()

void ELIST_ITERATOR::add_before_then_move ( ELIST_LINK new_link)
inline

Definition at line 427 of file elst.h.

428  {
429  #ifndef NDEBUG
430  if (!list)
431  NO_LIST.error ("ELIST_ITERATOR::add_before_then_move", ABORT, nullptr);
432  if (!new_element)
433  BAD_PARAMETER.error ("ELIST_ITERATOR::add_before_then_move", ABORT,
434  "new_element is nullptr");
435  if (new_element->next)
436  STILL_LINKED.error ("ELIST_ITERATOR::add_before_then_move", ABORT, nullptr);
437  #endif
438 
439  if (list->empty ()) {
440  new_element->next = new_element;
441  list->last = new_element;
442  prev = next = new_element;
443  }
444  else {
445  prev->next = new_element;
446  if (current) { //not extracted
447  new_element->next = current;
448  next = current;
449  }
450  else { //current extracted
451  new_element->next = next;
452  if (ex_current_was_last)
453  list->last = new_element;
454  if (ex_current_was_cycle_pt)
455  cycle_pt = new_element;
456  }
457  }
458  current = new_element;
459 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_list_after()

void ELIST_ITERATOR::add_list_after ( ELIST list_to_add)
inline

Definition at line 511 of file elst.h.

511  {
512  #ifndef NDEBUG
513  if (!list)
514  NO_LIST.error ("ELIST_ITERATOR::add_list_after", ABORT, nullptr);
515  if (!list_to_add)
516  BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_after", ABORT,
517  "list_to_add is nullptr");
518  #endif
519 
520  if (!list_to_add->empty ()) {
521  if (list->empty ()) {
522  list->last = list_to_add->last;
523  prev = list->last;
524  next = list->First ();
525  ex_current_was_last = TRUE;
526  current = nullptr;
527  }
528  else {
529  if (current) { //not extracted
530  current->next = list_to_add->First ();
531  if (current == list->last)
532  list->last = list_to_add->last;
533  list_to_add->last->next = next;
534  next = current->next;
535  }
536  else { //current extracted
537  prev->next = list_to_add->First ();
538  if (ex_current_was_last) {
539  list->last = list_to_add->last;
540  ex_current_was_last = FALSE;
541  }
542  list_to_add->last->next = next;
543  next = prev->next;
544  }
545  }
546  list_to_add->last = nullptr;
547  }
548 }
#define TRUE
Definition: capi.h:51
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define FALSE
Definition: capi.h:52
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_list_before()

void ELIST_ITERATOR::add_list_before ( ELIST list_to_add)
inline

Definition at line 559 of file elst.h.

559  {
560  #ifndef NDEBUG
561  if (!list)
562  NO_LIST.error ("ELIST_ITERATOR::add_list_before", ABORT, nullptr);
563  if (!list_to_add)
564  BAD_PARAMETER.error ("ELIST_ITERATOR::add_list_before", ABORT,
565  "list_to_add is nullptr");
566  #endif
567 
568  if (!list_to_add->empty ()) {
569  if (list->empty ()) {
570  list->last = list_to_add->last;
571  prev = list->last;
572  current = list->First ();
573  next = current->next;
574  ex_current_was_last = FALSE;
575  }
576  else {
577  prev->next = list_to_add->First ();
578  if (current) { //not extracted
579  list_to_add->last->next = current;
580  }
581  else { //current extracted
582  list_to_add->last->next = next;
583  if (ex_current_was_last)
584  list->last = list_to_add->last;
585  if (ex_current_was_cycle_pt)
586  cycle_pt = prev->next;
587  }
588  current = prev->next;
589  next = current->next;
590  }
591  list_to_add->last = nullptr;
592  }
593 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define FALSE
Definition: capi.h:52
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ add_to_end()

void ELIST_ITERATOR::add_to_end ( ELIST_LINK new_link)
inline

Definition at line 790 of file elst.h.

791  {
792  #ifndef NDEBUG
793  if (!list)
794  NO_LIST.error ("ELIST_ITERATOR::add_to_end", ABORT, nullptr);
795  if (!new_element)
796  BAD_PARAMETER.error ("ELIST_ITERATOR::add_to_end", ABORT,
797  "new_element is nullptr");
798  if (new_element->next)
799  STILL_LINKED.error ("ELIST_ITERATOR::add_to_end", ABORT, nullptr);
800  #endif
801 
802  if (this->at_last ()) {
803  this->add_after_stay_put (new_element);
804  }
805  else {
806  if (this->at_first ()) {
807  this->add_before_stay_put (new_element);
808  list->last = new_element;
809  }
810  else { //Iteratr is elsewhere
811  new_element->next = list->last->next;
812  list->last->next = new_element;
813  list->last = new_element;
814  }
815  }
816 }
void add_after_stay_put(ELIST_LINK *new_link)
Definition: elst.h:379
bool at_first()
Definition: elst.h:691
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE STILL_LINKED
Definition: lsterr.h:40
bool at_last()
Definition: elst.h:711
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void add_before_stay_put(ELIST_LINK *new_link)
Definition: elst.h:468
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ at_first()

bool ELIST_ITERATOR::at_first ( )
inline

Definition at line 691 of file elst.h.

691  {
692  #ifndef NDEBUG
693  if (!list)
694  NO_LIST.error ("ELIST_ITERATOR::at_first", ABORT, nullptr);
695  #endif
696 
697  //we're at a deleted
698  return ((list->empty ()) || (current == list->First ()) || ((current == nullptr) &&
699  (prev == list->last) && //NON-last pt between
700  !ex_current_was_last)); //first and last
701 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ at_last()

bool ELIST_ITERATOR::at_last ( )
inline

Definition at line 711 of file elst.h.

711  {
712  #ifndef NDEBUG
713  if (!list)
714  NO_LIST.error ("ELIST_ITERATOR::at_last", ABORT, nullptr);
715  #endif
716 
717  //we're at a deleted
718  return ((list->empty ()) || (current == list->last) || ((current == nullptr) &&
719  (prev == list->last) && //last point between
720  ex_current_was_last)); //first and last
721 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ current_extracted()

bool ELIST_ITERATOR::current_extracted ( )
inline

Definition at line 266 of file elst.h.

266  { //current extracted?
267  return !current;
268  }

◆ cycled_list()

bool ELIST_ITERATOR::cycled_list ( )
inline

Definition at line 731 of file elst.h.

731  {
732  #ifndef NDEBUG
733  if (!list)
734  NO_LIST.error ("ELIST_ITERATOR::cycled_list", ABORT, nullptr);
735  #endif
736 
737  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
738 
739 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ data()

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, nullptr);
239  if (!current)
240  NULL_DATA.error ("ELIST_ITERATOR::data", ABORT, nullptr);
241  #endif
242  return current;
243  }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ data_relative()

ELIST_LINK * ELIST_ITERATOR::data_relative ( int8_t  offset)

Definition at line 235 of file elst.cpp.

236  { //offset from current
237  ELIST_LINK *ptr;
238 
239  #ifndef NDEBUG
240  if (!list)
241  NO_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, nullptr);
242  if (list->empty ())
243  EMPTY_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, nullptr);
244  if (offset < -1)
245  BAD_PARAMETER.error ("ELIST_ITERATOR::data_relative", ABORT,
246  "offset < -l");
247  #endif
248 
249  if (offset == -1)
250  ptr = prev;
251  else
252  for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next);
253 
254  #ifndef NDEBUG
255  if (!ptr)
256  NULL_DATA.error ("ELIST_ITERATOR::data_relative", ABORT, nullptr);
257  #endif
258 
259  return ptr;
260 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_DATA
Definition: lsterr.h:34
const ERRCODE EMPTY_LIST
Definition: lsterr.h:38
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ empty()

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, nullptr);
262  #endif
263  return list->empty ();
264  }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ exchange()

void ELIST_ITERATOR::exchange ( ELIST_ITERATOR other_it)

Definition at line 292 of file elst.cpp.

293  { //other iterator
294  const ERRCODE DONT_EXCHANGE_DELETED =
295  "Can't exchange deleted elements of lists";
296 
297  ELIST_LINK *old_current;
298 
299  #ifndef NDEBUG
300  if (!list)
301  NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, nullptr);
302  if (!other_it)
303  BAD_PARAMETER.error ("ELIST_ITERATOR::exchange", ABORT, "other_it nullptr");
304  if (!(other_it->list))
305  NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, "other_it");
306  #endif
307 
308  /* Do nothing if either list is empty or if both iterators reference the same
309  link */
310 
311  if ((list->empty ()) ||
312  (other_it->list->empty ()) || (current == other_it->current))
313  return;
314 
315  /* Error if either current element is deleted */
316 
317  if (!current || !other_it->current)
318  DONT_EXCHANGE_DELETED.error ("ELIST_ITERATOR.exchange", ABORT, nullptr);
319 
320  /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
321  (other before this); non-doubleton adjacent elements (this before other);
322  non-adjacent elements. */
323 
324  //adjacent links
325  if ((next == other_it->current) ||
326  (other_it->next == current)) {
327  //doubleton list
328  if ((next == other_it->current) &&
329  (other_it->next == current)) {
330  prev = next = current;
331  other_it->prev = other_it->next = other_it->current;
332  }
333  else { //non-doubleton with
334  //adjacent links
335  //other before this
336  if (other_it->next == current) {
337  other_it->prev->next = current;
338  other_it->current->next = next;
339  current->next = other_it->current;
340  other_it->next = other_it->current;
341  prev = current;
342  }
343  else { //this before other
344  prev->next = other_it->current;
345  current->next = other_it->next;
346  other_it->current->next = current;
347  next = current;
348  other_it->prev = other_it->current;
349  }
350  }
351  }
352  else { //no overlap
353  prev->next = other_it->current;
354  current->next = other_it->next;
355  other_it->prev->next = current;
356  other_it->current->next = next;
357  }
358 
359  /* update end of list pointer when necessary (remember that the 2 iterators
360  may iterate over different lists!) */
361 
362  if (list->last == current)
363  list->last = other_it->current;
364  if (other_it->list->last == other_it->current)
365  other_it->list->last = current;
366 
367  if (current == cycle_pt)
368  cycle_pt = other_it->cycle_pt;
369  if (other_it->current == other_it->cycle_pt)
370  other_it->cycle_pt = cycle_pt;
371 
372  /* The actual exchange - in all cases*/
373 
374  old_current = current;
375  current = other_it->current;
376  other_it->current = old_current;
377 }
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
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:37

◆ extract()

ELIST_LINK * ELIST_ITERATOR::extract ( )
inline

Definition at line 605 of file elst.h.

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

◆ forward()

ELIST_LINK * ELIST_ITERATOR::forward ( )

Definition at line 194 of file elst.cpp.

194  {
195  #ifndef NDEBUG
196  if (!list)
197  NO_LIST.error ("ELIST_ITERATOR::forward", ABORT, nullptr);
198  #endif
199  if (list->empty ())
200  return nullptr;
201 
202  if (current) { //not removed so
203  //set previous
204  prev = current;
205  started_cycling = TRUE;
206  // In case next is deleted by another iterator, get next from current.
207  current = current->next;
208  } else {
209  if (ex_current_was_cycle_pt)
210  cycle_pt = next;
211  current = next;
212  }
213 #ifndef NDEBUG
214  if (!current)
215  NULL_DATA.error ("ELIST_ITERATOR::forward", ABORT, nullptr);
216 #endif
217  next = current->next;
218 
219  #ifndef NDEBUG
220  if (!next)
221  NULL_NEXT.error ("ELIST_ITERATOR::forward", ABORT,
222  "This is: %p Current is: %p", this, current);
223  #endif
224  return current;
225 }
#define TRUE
Definition: capi.h:51
bool empty() const
Definition: elst.h:132
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
const ERRCODE NULL_NEXT
Definition: lsterr.h:36
const ERRCODE NULL_DATA
Definition: lsterr.h:34
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ length()

int32_t ELIST_ITERATOR::length ( )
inline

Definition at line 749 of file elst.h.

749  {
750  #ifndef NDEBUG
751  if (!list)
752  NO_LIST.error ("ELIST_ITERATOR::length", ABORT, nullptr);
753  #endif
754 
755  return list->length ();
756 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
int32_t length() const
Definition: elst.cpp:90
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ mark_cycle_pt()

void ELIST_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 670 of file elst.h.

670  {
671  #ifndef NDEBUG
672  if (!list)
673  NO_LIST.error ("ELIST_ITERATOR::mark_cycle_pt", ABORT, nullptr);
674  #endif
675 
676  if (current)
677  cycle_pt = current;
678  else
679  ex_current_was_cycle_pt = TRUE;
680  started_cycling = FALSE;
681 }
#define TRUE
Definition: capi.h:51
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
#define FALSE
Definition: capi.h:52
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ move_to_first()

ELIST_LINK * ELIST_ITERATOR::move_to_first ( )
inline

Definition at line 646 of file elst.h.

646  {
647  #ifndef NDEBUG
648  if (!list)
649  NO_LIST.error ("ELIST_ITERATOR::move_to_first", ABORT, nullptr);
650  #endif
651 
652  current = list->First ();
653  prev = list->last;
654  next = current ? current->next : nullptr;
655  return current;
656 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ move_to_last()

ELIST_LINK * ELIST_ITERATOR::move_to_last ( )

Definition at line 270 of file elst.cpp.

270  {
271  #ifndef NDEBUG
272  if (!list)
273  NO_LIST.error ("ELIST_ITERATOR::move_to_last", ABORT, nullptr);
274  #endif
275 
276  while (current != list->last)
277  forward();
278 
279  return current;
280 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
ELIST_LINK * forward()
Definition: elst.cpp:194
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ set_to_list()

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 (!list_to_iterate)
301  BAD_PARAMETER.error ("ELIST_ITERATOR::set_to_list", ABORT,
302  "list_to_iterate is nullptr");
303  #endif
304 
305  list = list_to_iterate;
306  prev = list->last;
307  current = list->First ();
308  next = current ? current->next : nullptr;
309  cycle_pt = nullptr; //await explicit set
310  started_cycling = FALSE;
311  ex_current_was_last = FALSE;
312  ex_current_was_cycle_pt = FALSE;
313 }
Definition: errcode.h:30
#define FALSE
Definition: capi.h:52
const ERRCODE BAD_PARAMETER
Definition: lsterr.h:39
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

◆ sort()

void ELIST_ITERATOR::sort ( int   comparator const void *, const void *)
inline

Definition at line 767 of file elst.h.

769  {
770  #ifndef NDEBUG
771  if (!list)
772  NO_LIST.error ("ELIST_ITERATOR::sort", ABORT, nullptr);
773  #endif
774 
775  list->sort (comparator);
776  move_to_first();
777 }
const ERRCODE NO_LIST
Definition: lsterr.h:32
Definition: errcode.h:30
ELIST_LINK * move_to_first()
Definition: elst.h:646
void sort(int comparator(const void *, const void *))
Definition: elst.cpp:108
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:37

Friends And Related Function Documentation

◆ ELIST::assign_to_sublist


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