tesseract  4.1.0
ELIST2_ITERATOR Class Reference

#include <elst2.h>

Public Member Functions

 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_t offset)
 
ELIST2_LINKforward ()
 
ELIST2_LINKbackward ()
 
ELIST2_LINKextract ()
 
ELIST2_LINKmove_to_first ()
 
ELIST2_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 (ELIST2_LINK *new_link)
 
void exchange (ELIST2_ITERATOR *other_it)
 
int32_t length ()
 
void sort (int comparator( const void *, const void *))
 

Friends

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

Detailed Description

Definition at line 149 of file elst2.h.

Constructor & Destructor Documentation

ELIST2_ITERATOR::ELIST2_ITERATOR ( ELIST2 list_to_iterate)
inline

Definition at line 286 of file elst2.h.

286  {
287  set_to_list(list_to_iterate);
288 }
void set_to_list(ELIST2 *list_to_iterate)
Definition: elst2.h:262

Member Function Documentation

void ELIST2_ITERATOR::add_after_stay_put ( ELIST2_LINK new_link)
inline

Definition at line 345 of file elst2.h.

346  {
347  #ifndef NDEBUG
348  if (!list)
349  NO_LIST.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT, nullptr);
350  if (!new_element)
351  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT,
352  "new_element is nullptr");
353  if (new_element->next)
354  STILL_LINKED.error ("ELIST2_ITERATOR::add_after_stay_put", ABORT, nullptr);
355  #endif
356 
357  if (list->empty ()) {
358  new_element->next = new_element;
359  new_element->prev = new_element;
360  list->last = new_element;
361  prev = next = new_element;
362  ex_current_was_last = false;
363  current = nullptr;
364  }
365  else {
366  new_element->next = next;
367  next->prev = new_element;
368 
369  if (current) { //not extracted
370  new_element->prev = current;
371  current->next = new_element;
372  if (prev == current)
373  prev = new_element;
374  if (current == list->last)
375  list->last = new_element;
376  }
377  else { //current extracted
378  new_element->prev = prev;
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 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_after_then_move ( ELIST2_LINK new_link)
inline

Definition at line 297 of file elst2.h.

298  {
299  #ifndef NDEBUG
300  if (!list)
301  NO_LIST.error ("ELIST2_ITERATOR::add_after_then_move", ABORT, nullptr);
302  if (!new_element)
303  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_after_then_move", ABORT,
304  "new_element is nullptr");
305  if (new_element->next)
306  STILL_LINKED.error ("ELIST2_ITERATOR::add_after_then_move", ABORT, nullptr);
307  #endif
308 
309  if (list->empty ()) {
310  new_element->next = new_element;
311  new_element->prev = new_element;
312  list->last = new_element;
313  prev = next = new_element;
314  }
315  else {
316  new_element->next = next;
317  next->prev = new_element;
318 
319  if (current) { //not extracted
320  new_element->prev = current;
321  current->next = new_element;
322  prev = current;
323  if (current == list->last)
324  list->last = new_element;
325  }
326  else { //current extracted
327  new_element->prev = prev;
328  prev->next = new_element;
329  if (ex_current_was_last)
330  list->last = new_element;
331  if (ex_current_was_cycle_pt)
332  cycle_pt = new_element;
333  }
334  }
335  current = new_element;
336 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_before_stay_put ( ELIST2_LINK new_link)
inline

Definition at line 442 of file elst2.h.

443  {
444  #ifndef NDEBUG
445  if (!list)
446  NO_LIST.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT, nullptr);
447  if (!new_element)
448  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT,
449  "new_element is nullptr");
450  if (new_element->next)
451  STILL_LINKED.error ("ELIST2_ITERATOR::add_before_stay_put", ABORT, nullptr);
452  #endif
453 
454  if (list->empty ()) {
455  new_element->next = new_element;
456  new_element->prev = new_element;
457  list->last = new_element;
458  prev = next = new_element;
459  ex_current_was_last = true;
460  current = nullptr;
461  }
462  else {
463  prev->next = new_element;
464  new_element->prev = prev;
465 
466  if (current) { //not extracted
467  new_element->next = current;
468  current->prev = new_element;
469  if (next == current)
470  next = new_element;
471  }
472  else { //current extracted
473  new_element->next = next;
474  next->prev = new_element;
475  if (ex_current_was_last)
476  list->last = new_element;
477  }
478  prev = new_element;
479  }
480 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_before_then_move ( ELIST2_LINK new_link)
inline

Definition at line 396 of file elst2.h.

397  {
398  #ifndef NDEBUG
399  if (!list)
400  NO_LIST.error ("ELIST2_ITERATOR::add_before_then_move", ABORT, nullptr);
401  if (!new_element)
402  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_before_then_move", ABORT,
403  "new_element is nullptr");
404  if (new_element->next)
405  STILL_LINKED.error ("ELIST2_ITERATOR::add_before_then_move", ABORT, nullptr);
406  #endif
407 
408  if (list->empty ()) {
409  new_element->next = new_element;
410  new_element->prev = new_element;
411  list->last = new_element;
412  prev = next = new_element;
413  }
414  else {
415  prev->next = new_element;
416  new_element->prev = prev;
417 
418  if (current) { //not extracted
419  new_element->next = current;
420  current->prev = new_element;
421  next = current;
422  }
423  else { //current extracted
424  new_element->next = next;
425  next->prev = new_element;
426  if (ex_current_was_last)
427  list->last = new_element;
428  if (ex_current_was_cycle_pt)
429  cycle_pt = new_element;
430  }
431  }
432  current = new_element;
433 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_list_after ( ELIST2 list_to_add)
inline

Definition at line 490 of file elst2.h.

490  {
491  #ifndef NDEBUG
492  if (!list)
493  NO_LIST.error ("ELIST2_ITERATOR::add_list_after", ABORT, nullptr);
494  if (!list_to_add)
495  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_list_after", ABORT,
496  "list_to_add is nullptr");
497  #endif
498 
499  if (!list_to_add->empty ()) {
500  if (list->empty ()) {
501  list->last = list_to_add->last;
502  prev = list->last;
503  next = list->First ();
504  ex_current_was_last = true;
505  current = nullptr;
506  }
507  else {
508  if (current) { //not extracted
509  current->next = list_to_add->First ();
510  current->next->prev = current;
511  if (current == list->last)
512  list->last = list_to_add->last;
513  list_to_add->last->next = next;
514  next->prev = list_to_add->last;
515  next = current->next;
516  }
517  else { //current extracted
518  prev->next = list_to_add->First ();
519  prev->next->prev = prev;
520  if (ex_current_was_last) {
521  list->last = list_to_add->last;
522  ex_current_was_last = false;
523  }
524  list_to_add->last->next = next;
525  next->prev = list_to_add->last;
526  next = prev->next;
527  }
528  }
529  list_to_add->last = nullptr;
530  }
531 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_list_before ( ELIST2 list_to_add)
inline

Definition at line 541 of file elst2.h.

541  {
542  #ifndef NDEBUG
543  if (!list)
544  NO_LIST.error ("ELIST2_ITERATOR::add_list_before", ABORT, nullptr);
545  if (!list_to_add)
546  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_list_before", ABORT,
547  "list_to_add is nullptr");
548  #endif
549 
550  if (!list_to_add->empty ()) {
551  if (list->empty ()) {
552  list->last = list_to_add->last;
553  prev = list->last;
554  current = list->First ();
555  next = current->next;
556  ex_current_was_last = false;
557  }
558  else {
559  prev->next = list_to_add->First ();
560  prev->next->prev = prev;
561 
562  if (current) { //not extracted
563  list_to_add->last->next = current;
564  current->prev = list_to_add->last;
565  }
566  else { //current extracted
567  list_to_add->last->next = next;
568  next->prev = list_to_add->last;
569  if (ex_current_was_last)
570  list->last = list_to_add->last;
571  if (ex_current_was_cycle_pt)
572  cycle_pt = prev->next;
573  }
574  current = prev->next;
575  next = current->next;
576  }
577  list_to_add->last = nullptr;
578  }
579 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::add_to_end ( ELIST2_LINK new_link)
inline

Definition at line 788 of file elst2.h.

789  {
790  #ifndef NDEBUG
791  if (!list)
792  NO_LIST.error ("ELIST2_ITERATOR::add_to_end", ABORT, nullptr);
793  if (!new_element)
794  BAD_PARAMETER.error ("ELIST2_ITERATOR::add_to_end", ABORT,
795  "new_element is nullptr");
796  if (new_element->next)
797  STILL_LINKED.error ("ELIST2_ITERATOR::add_to_end", ABORT, nullptr);
798  #endif
799 
800  if (this->at_last ()) {
801  this->add_after_stay_put (new_element);
802  }
803  else {
804  if (this->at_first ()) {
805  this->add_before_stay_put (new_element);
806  list->last = new_element;
807  }
808  else { //Iteratr is elsewhere
809  new_element->next = list->last->next;
810  new_element->prev = list->last;
811  list->last->next->prev = new_element;
812  list->last->next = new_element;
813  list->last = new_element;
814  }
815  }
816 }
bool at_last()
Definition: elst2.h:713
bool at_first()
Definition: elst2.h:694
void add_after_stay_put(ELIST2_LINK *new_link)
Definition: elst2.h:345
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
void add_before_stay_put(ELIST2_LINK *new_link)
Definition: elst2.h:442
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE STILL_LINKED("Attempting to add an element with non nullptr links, to a list")
bool ELIST2_ITERATOR::at_first ( )
inline

Definition at line 694 of file elst2.h.

694  {
695  #ifndef NDEBUG
696  if (!list)
697  NO_LIST.error ("ELIST2_ITERATOR::at_first", ABORT, nullptr);
698  #endif
699 
700  //we're at a deleted
701  return ((list->empty ()) || (current == list->First ()) || ((current == nullptr) &&
702  (prev == list->last) && //NON-last pt between
703  !ex_current_was_last)); //first and last
704 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
bool ELIST2_ITERATOR::at_last ( )
inline

Definition at line 713 of file elst2.h.

713  {
714  #ifndef NDEBUG
715  if (!list)
716  NO_LIST.error ("ELIST2_ITERATOR::at_last", ABORT, nullptr);
717  #endif
718 
719  //we're at a deleted
720  return ((list->empty ()) || (current == list->last) || ((current == nullptr) &&
721  (prev == list->last) && //last point between
722  ex_current_was_last)); //first and last
723 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
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, nullptr);
233  #endif
234  if (list->empty ())
235  return nullptr;
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 
249  #ifndef NDEBUG
250  if (!current)
251  NULL_DATA.error ("ELIST2_ITERATOR::backward", ABORT, nullptr);
252  if (!prev)
253  NULL_PREV.error ("ELIST2_ITERATOR::backward", ABORT,
254  "This is: %p Current is: %p", this, current);
255  #endif
256 
257  prev = current->prev;
258  return current;
259 }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
constexpr ERRCODE NULL_PREV("Previous element on the list is nullptr")
bool ELIST2_ITERATOR::current_extracted ( )
inline

Definition at line 228 of file elst2.h.

228  { //current extracted?
229  return !current;
230  }
bool ELIST2_ITERATOR::cycled_list ( )
inline

Definition at line 732 of file elst2.h.

732  {
733  #ifndef NDEBUG
734  if (!list)
735  NO_LIST.error ("ELIST2_ITERATOR::cycled_list", ABORT, nullptr);
736  #endif
737 
738  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));
739 
740 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
ELIST2_LINK* ELIST2_ITERATOR::data ( )
inline

Definition at line 194 of file elst2.h.

194  { //get current data
195  #ifndef NDEBUG
196  if (!current)
197  NULL_DATA.error ("ELIST2_ITERATOR::data", ABORT, nullptr);
198  if (!list)
199  NO_LIST.error ("ELIST2_ITERATOR::data", ABORT, nullptr);
200  #endif
201  return current;
202  }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
ELIST2_LINK * ELIST2_ITERATOR::data_relative ( int8_t  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, nullptr);
275  if (list->empty ())
276  EMPTY_LIST.error ("ELIST2_ITERATOR::data_relative", ABORT, nullptr);
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, nullptr);
287  #endif
288 
289  return ptr;
290 }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE EMPTY_LIST("List is empty")
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
bool ELIST2_ITERATOR::empty ( )
inline

Definition at line 220 of file elst2.h.

220  { //is list empty?
221  #ifndef NDEBUG
222  if (!list)
223  NO_LIST.error ("ELIST2_ITERATOR::empty", ABORT, nullptr);
224  #endif
225  return list->empty ();
226  }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
bool empty() const
Definition: elst2.h:105
void ELIST2_ITERATOR::exchange ( ELIST2_ITERATOR other_it)

Definition at line 302 of file elst2.cpp.

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

Definition at line 590 of file elst2.h.

590  {
591  ELIST2_LINK *extracted_link;
592 
593  #ifndef NDEBUG
594  if (!list)
595  NO_LIST.error ("ELIST2_ITERATOR::extract", ABORT, nullptr);
596  if (!current) //list empty or
597  //element extracted
598  NULL_CURRENT.error ("ELIST2_ITERATOR::extract",
599  ABORT, nullptr);
600  #endif
601 
602  if (list->singleton()) {
603  // Special case where we do need to change the iterator.
604  prev = next = list->last = nullptr;
605  } else {
606  prev->next = next; //remove from list
607  next->prev = prev;
608 
609  if (current == list->last) {
610  list->last = prev;
611  ex_current_was_last = true;
612  } else {
613  ex_current_was_last = false;
614  }
615  }
616  // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
617  ex_current_was_cycle_pt = (current == cycle_pt);
618  extracted_link = current;
619  extracted_link->next = nullptr; //for safety
620  extracted_link->prev = nullptr; //for safety
621  current = nullptr;
622  return extracted_link;
623 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_CURRENT("List current position is nullptr")
bool singleton() const
Definition: elst2.h:109
ELIST2_LINK * ELIST2_ITERATOR::forward ( )

Definition at line 185 of file elst2.cpp.

185  {
186  #ifndef NDEBUG
187  if (!list)
188  NO_LIST.error ("ELIST2_ITERATOR::forward", ABORT, nullptr);
189  #endif
190  if (list->empty ())
191  return nullptr;
192 
193  if (current) { //not removed so
194  //set previous
195  prev = current;
196  started_cycling = true;
197  // In case next is deleted by another iterator, get it from the current.
198  current = current->next;
199  }
200  else {
201  if (ex_current_was_cycle_pt)
202  cycle_pt = next;
203  current = next;
204  }
205 
206 #ifndef NDEBUG
207  if (!current)
208  NULL_DATA.error ("ELIST2_ITERATOR::forward", ABORT, nullptr);
209 #endif
210 
211  next = current->next;
212 
213 #ifndef NDEBUG
214  if (!next)
215  NULL_NEXT.error ("ELIST2_ITERATOR::forward", ABORT,
216  "This is: %p Current is: %p", this, current);
217 #endif
218 
219  return current;
220 }
constexpr ERRCODE NULL_DATA("List would have returned a nullptr data pointer")
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
constexpr ERRCODE NULL_NEXT("Next element on the list is nullptr")
bool empty() const
Definition: elst2.h:105
int32_t ELIST2_ITERATOR::length ( )
inline

Definition at line 749 of file elst2.h.

749  {
750  #ifndef NDEBUG
751  if (!list)
752  NO_LIST.error ("ELIST2_ITERATOR::length", ABORT, nullptr);
753  #endif
754 
755  return list->length ();
756 }
int32_t length() const
Definition: elst2.cpp:89
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void ELIST2_ITERATOR::mark_cycle_pt ( )
inline

Definition at line 674 of file elst2.h.

674  {
675  #ifndef NDEBUG
676  if (!list)
677  NO_LIST.error ("ELIST2_ITERATOR::mark_cycle_pt", ABORT, nullptr);
678  #endif
679 
680  if (current)
681  cycle_pt = current;
682  else
683  ex_current_was_cycle_pt = true;
684  started_cycling = false;
685 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
ELIST2_LINK * ELIST2_ITERATOR::move_to_first ( )
inline

Definition at line 632 of file elst2.h.

632  {
633  #ifndef NDEBUG
634  if (!list)
635  NO_LIST.error ("ELIST2_ITERATOR::move_to_first", ABORT, nullptr);
636  #endif
637 
638  current = list->First ();
639  prev = list->last;
640  next = current ? current->next : nullptr;
641  return current;
642 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
ELIST2_LINK * ELIST2_ITERATOR::move_to_last ( )
inline

Definition at line 651 of file elst2.h.

651  {
652  #ifndef NDEBUG
653  if (!list)
654  NO_LIST.error ("ELIST2_ITERATOR::move_to_last", ABORT, nullptr);
655  #endif
656 
657  current = list->last;
658  prev = current ? current->prev : nullptr;
659  next = current ? current->next : nullptr;
660  return current;
661 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void ELIST2_ITERATOR::set_to_list ( ELIST2 list_to_iterate)
inline

Definition at line 262 of file elst2.h.

263  {
264  #ifndef NDEBUG
265  if (!list_to_iterate)
266  BAD_PARAMETER.error ("ELIST2_ITERATOR::set_to_list", ABORT,
267  "list_to_iterate is nullptr");
268  #endif
269 
270  list = list_to_iterate;
271  prev = list->last;
272  current = list->First ();
273  next = current ? current->next : nullptr;
274  cycle_pt = nullptr; //await explicit set
275  started_cycling = false;
276  ex_current_was_last = false;
277  ex_current_was_cycle_pt = false;
278 }
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
constexpr ERRCODE BAD_PARAMETER("List parameter error")
Definition: errcode.h:29
void ELIST2_ITERATOR::sort ( int   comparator const void *, const void *)
inline

Definition at line 766 of file elst2.h.

768  {
769  #ifndef NDEBUG
770  if (!list)
771  NO_LIST.error ("ELIST2_ITERATOR::sort", ABORT, nullptr);
772  #endif
773 
774  list->sort (comparator);
775  move_to_first();
776 }
ELIST2_LINK * move_to_first()
Definition: elst2.h:632
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35
Definition: errcode.h:29
constexpr ERRCODE NO_LIST("Iterator not set to a list")
void sort(int comparator( const void *, const void *))
Definition: elst2.cpp:107

Friends And Related Function Documentation


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