Coverage Report

Created: 2025-07-12 06:44

/src/tesseract/src/ccutil/elst.h
Line
Count
Source (jump to first uncovered line)
1
/**********************************************************************
2
 * File:        elst.h  (Formerly elist.h)
3
 * Description: Embedded list module include file.
4
 * Author:      Phil Cheatle
5
 *
6
 * (C) Copyright 1991, Hewlett-Packard Ltd.
7
 ** Licensed under the Apache License, Version 2.0 (the "License");
8
 ** you may not use this file except in compliance with the License.
9
 ** You may obtain a copy of the License at
10
 ** http://www.apache.org/licenses/LICENSE-2.0
11
 ** Unless required by applicable law or agreed to in writing, software
12
 ** distributed under the License is distributed on an "AS IS" BASIS,
13
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 ** See the License for the specific language governing permissions and
15
 ** limitations under the License.
16
 *
17
 **********************************************************************/
18
19
#ifndef ELST_H
20
#define ELST_H
21
22
#include "lsterr.h"
23
#include "serialis.h"
24
25
#include <algorithm>
26
#include <cstdio>
27
28
namespace tesseract {
29
30
/**********************************************************************
31
This module implements list classes and iterators.
32
The following list types and iterators are provided:
33
34
  List type        List Class      Iterator Class     Element Class
35
  ---------         ----------      --------------      -------------
36
37
    Embedded list       ELIST
38
              ELIST_ITERATOR
39
              ELIST_LINK
40
    (Single linked)
41
42
    Embedded list       ELIST2
43
              ELIST2_ITERATOR
44
              ELIST2_LINK
45
    (Double linked)
46
47
    Cons List           CLIST
48
              CLIST_ITERATOR
49
              CLIST_LINK
50
    (Single linked)
51
52
An embedded list is where the list pointers are provided by a generic class.
53
Data types to be listed inherit from the generic class.  Data is thus linked
54
in only ONE list at any one time.
55
56
A cons list has a separate structure for a "cons cell".  This contains the
57
list pointer(s) AND a pointer to the data structure held on the list.  A
58
structure can be on many cons lists at the same time, and the structure does
59
not need to inherit from any generic class in order to be on the list.
60
61
The implementation of lists is very careful about space and speed overheads.
62
This is why many embedded lists are provided. The same concerns mean that
63
in-line type coercion is done, rather than use virtual functions.  This is
64
cumbersome in that each data type to be listed requires its own iterator and
65
list class - though macros can generate these.  It also prevents heterogeneous
66
lists.
67
**********************************************************************/
68
69
/**********************************************************************
70
 * CLASS - ELIST
71
 *
72
 * Generic list class for singly linked lists with embedded links
73
 **********************************************************************/
74
75
template <typename T>
76
class IntrusiveForwardList {
77
public:
78
  /**********************************************************************
79
   *                          CLASS - ELIST_LINK
80
   *
81
   *                          Generic link class for singly linked lists with
82
   *embedded links
83
   *
84
   *  Note:  No destructor - elements are assumed to be destroyed EITHER after
85
   *  they have been extracted from a list OR by the IntrusiveForwardList destructor which
86
   *  walks the list.
87
   **********************************************************************/
88
89
  class Link {
90
    friend class Iterator;
91
    friend class IntrusiveForwardList;
92
93
    T *next;
94
95
  public:
96
64.3M
    Link() {
97
64.3M
      next = nullptr;
98
64.3M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link::Link()
Line
Count
Source
96
3.15M
    Link() {
97
3.15M
      next = nullptr;
98
3.15M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link::Link()
Line
Count
Source
96
771k
    Link() {
97
771k
      next = nullptr;
98
771k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Link::Link()
Line
Count
Source
96
4.13M
    Link() {
97
4.13M
      next = nullptr;
98
4.13M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Link::Link()
Line
Count
Source
96
4.67M
    Link() {
97
4.67M
      next = nullptr;
98
4.67M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Link::Link()
Line
Count
Source
96
1.75M
    Link() {
97
1.75M
      next = nullptr;
98
1.75M
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Link::Link()
Line
Count
Source
96
24.9k
    Link() {
97
24.9k
      next = nullptr;
98
24.9k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Link::Link()
Line
Count
Source
96
3.30M
    Link() {
97
3.30M
      next = nullptr;
98
3.30M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Link::Link()
Line
Count
Source
96
19.1k
    Link() {
97
19.1k
      next = nullptr;
98
19.1k
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link::Link()
Line
Count
Source
96
19.1M
    Link() {
97
19.1M
      next = nullptr;
98
19.1M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Link::Link()
Line
Count
Source
96
19.1k
    Link() {
97
19.1k
      next = nullptr;
98
19.1k
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Link::Link()
Line
Count
Source
96
202k
    Link() {
97
202k
      next = nullptr;
98
202k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Link::Link()
Line
Count
Source
96
17.2k
    Link() {
97
17.2k
      next = nullptr;
98
17.2k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Link::Link()
Line
Count
Source
96
160k
    Link() {
97
160k
      next = nullptr;
98
160k
    }
tesseract::IntrusiveForwardList<tesseract::TrainingSample>::Link::Link()
Line
Count
Source
96
2.01M
    Link() {
97
2.01M
      next = nullptr;
98
2.01M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Link::Link()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColPartitionSet>::Link::Link()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Link::Link()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Link::Link()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Link::Link()
Line
Count
Source
96
22.3M
    Link() {
97
22.3M
      next = nullptr;
98
22.3M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Link::Link()
Line
Count
Source
96
76.1k
    Link() {
97
76.1k
      next = nullptr;
98
76.1k
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Link::Link()
Line
Count
Source
96
221k
    Link() {
97
221k
      next = nullptr;
98
221k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Link::Link()
Line
Count
Source
96
1.33M
    Link() {
97
1.33M
      next = nullptr;
98
1.33M
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Link::Link()
Line
Count
Source
96
879k
    Link() {
97
879k
      next = nullptr;
98
879k
    }
99
    // constructor
100
101
    // The special copy constructor is used by lots of classes.
102
1.24M
    Link(const Link &) {
103
1.24M
      next = nullptr;
104
1.24M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link::Link(tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link const&)
Line
Count
Source
102
30.1k
    Link(const Link &) {
103
30.1k
      next = nullptr;
104
30.1k
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link::Link(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link const&)
Line
Count
Source
102
1.13M
    Link(const Link &) {
103
1.13M
      next = nullptr;
104
1.13M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link::Link(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link const&)
Line
Count
Source
102
82.4k
    Link(const Link &) {
103
82.4k
      next = nullptr;
104
82.4k
    }
105
106
    // The special assignment operator is used by lots of classes.
107
30.1k
    void operator=(const Link &) {
108
30.1k
      next = nullptr;
109
30.1k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Link::operator=(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Link const&)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Link::operator=(tesseract::IntrusiveForwardList<tesseract::BLOCK>::Link const&)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Link::operator=(tesseract::IntrusiveForwardList<tesseract::ROW>::Link const&)
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link::operator=(tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link const&)
Line
Count
Source
107
30.1k
    void operator=(const Link &) {
108
30.1k
      next = nullptr;
109
30.1k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link::operator=(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link const&)
110
  };
111
  using LINK = Link; // compat
112
113
  /***********************************************************************
114
   *                          CLASS - ELIST_ITERATOR
115
   *
116
   *                          Generic iterator class for singly linked lists with
117
   *embedded links
118
   **********************************************************************/
119
120
  class Iterator {
121
    friend void IntrusiveForwardList::assign_to_sublist(Iterator *, Iterator *);
122
123
    IntrusiveForwardList *list;                  // List being iterated
124
    T *prev;             // prev element
125
    T *current;          // current element
126
    T *next;             // next element
127
    T *cycle_pt;         // point we are cycling the list to.
128
    bool ex_current_was_last;     // current extracted was end of list
129
    bool ex_current_was_cycle_pt; // current extracted was cycle point
130
    bool started_cycling;         // Have we moved off the start?
131
    /***********************************************************************
132
   *              Iterator::extract_sublist()
133
   *
134
   *  This is a private member, used only by IntrusiveForwardList::assign_to_sublist.
135
   *  Given another iterator for the same list, extract the links from THIS to
136
   *  OTHER inclusive, link them into a new circular list, and return a
137
   *  pointer to the last element.
138
   *  (Can't inline this function because it contains a loop)
139
   **********************************************************************/
140
    T *extract_sublist(   // from this current...
141
0
      Iterator *other_it) {              // to other current
142
#ifndef NDEBUG
143
      constexpr ERRCODE BAD_EXTRACTION_PTS("Can't extract sublist from points on different lists");
144
      constexpr ERRCODE DONT_EXTRACT_DELETED("Can't extract a sublist marked by deleted points");
145
#endif
146
0
      constexpr ERRCODE BAD_SUBLIST("Can't find sublist end point in original list");
147
148
0
      Iterator temp_it = *this;
149
0
      T *end_of_new_list;
150
151
#ifndef NDEBUG
152
      if (!other_it)
153
        BAD_PARAMETER.error("ELIST_ITERATOR::extract_sublist", ABORT, "other_it nullptr");
154
      if (!list)
155
        NO_LIST.error("ELIST_ITERATOR::extract_sublist", ABORT);
156
      if (list != other_it->list)
157
        BAD_EXTRACTION_PTS.error("ELIST_ITERATOR.extract_sublist", ABORT);
158
      if (list->empty())
159
        EMPTY_LIST.error("ELIST_ITERATOR::extract_sublist", ABORT);
160
161
      if (!current || !other_it->current)
162
        DONT_EXTRACT_DELETED.error("ELIST_ITERATOR.extract_sublist", ABORT);
163
#endif
164
165
0
      ex_current_was_last = other_it->ex_current_was_last = false;
166
0
      ex_current_was_cycle_pt = false;
167
0
      other_it->ex_current_was_cycle_pt = false;
168
169
0
      temp_it.mark_cycle_pt();
170
0
      do {                         // walk sublist
171
0
        if (temp_it.cycled_list()) { // can't find end pt
172
0
          BAD_SUBLIST.error("Iterator.extract_sublist", ABORT);
173
0
        }
174
175
0
        if (temp_it.at_last()) {
176
0
          list->last = prev;
177
0
          ex_current_was_last = other_it->ex_current_was_last = true;
178
0
        }
179
180
0
        if (temp_it.current == cycle_pt) {
181
0
          ex_current_was_cycle_pt = true;
182
0
        }
183
184
0
        if (temp_it.current == other_it->cycle_pt) {
185
0
          other_it->ex_current_was_cycle_pt = true;
186
0
        }
187
188
0
        temp_it.forward();
189
0
      } while (temp_it.prev != other_it->current);
190
191
      // circularise sublist
192
0
      other_it->current->next = current;
193
0
      end_of_new_list = other_it->current;
194
195
      // sublist = whole list
196
0
      if (prev == other_it->current) {
197
0
        list->last = nullptr;
198
0
        prev = current = next = nullptr;
199
0
        other_it->prev = other_it->current = other_it->next = nullptr;
200
0
      } else {
201
0
        prev->next = other_it->next;
202
0
        current = other_it->current = nullptr;
203
0
        next = other_it->next;
204
0
        other_it->prev = prev;
205
0
      }
206
0
      return end_of_new_list;
207
0
    } // to other current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::extract_sublist(tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::extract_sublist(tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator*)
208
209
  public:
210
88.0M
    Iterator() { // constructor
211
88.0M
      list = nullptr;
212
88.0M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::Iterator()
Line
Count
Source
210
1.02M
    Iterator() { // constructor
211
1.02M
      list = nullptr;
212
1.02M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::Iterator()
Line
Count
Source
210
1.02M
    Iterator() { // constructor
211
1.02M
      list = nullptr;
212
1.02M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::Iterator()
Line
Count
Source
210
3.08M
    Iterator() { // constructor
211
3.08M
      list = nullptr;
212
3.08M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::Iterator()
Line
Count
Source
210
7.75M
    Iterator() { // constructor
211
7.75M
      list = nullptr;
212
7.75M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::Iterator()
Line
Count
Source
210
537k
    Iterator() { // constructor
211
537k
      list = nullptr;
212
537k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::Iterator()
Line
Count
Source
210
76.7k
    Iterator() { // constructor
211
76.7k
      list = nullptr;
212
76.7k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::Iterator()
Line
Count
Source
210
6.95M
    Iterator() { // constructor
211
6.95M
      list = nullptr;
212
6.95M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::Iterator()
Line
Count
Source
210
2.48M
    Iterator() { // constructor
211
2.48M
      list = nullptr;
212
2.48M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::Iterator()
Line
Count
Source
210
4.08M
    Iterator() { // constructor
211
4.08M
      list = nullptr;
212
4.08M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::Iterator()
Line
Count
Source
210
19.1k
    Iterator() { // constructor
211
19.1k
      list = nullptr;
212
19.1k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::Iterator()
Line
Count
Source
210
60.6M
    Iterator() { // constructor
211
60.6M
      list = nullptr;
212
60.6M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::Iterator()
Line
Count
Source
210
202k
    Iterator() { // constructor
211
202k
      list = nullptr;
212
202k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::Iterator()
Line
Count
Source
210
138k
    Iterator() { // constructor
211
138k
      list = nullptr;
212
138k
    } // unassigned list
213
    /***********************************************************************
214
   *                          ELIST_ITERATOR::ELIST_ITERATOR
215
   *
216
   *  CONSTRUCTOR - set iterator to specified list;
217
   **********************************************************************/
218
344M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
344M
      set_to_list(list_to_iterate);
220
344M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
Line
Count
Source
218
134k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
134k
      set_to_list(list_to_iterate);
220
134k
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ROW>*)
Line
Count
Source
218
68.3k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
68.3k
      set_to_list(list_to_iterate);
220
68.3k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
218
12.7M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
12.7M
      set_to_list(list_to_iterate);
220
12.7M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>*)
Line
Count
Source
218
40.2M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
40.2M
      set_to_list(list_to_iterate);
220
40.2M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::AmbigSpec>*)
Line
Count
Source
218
6.56M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
6.56M
      set_to_list(list_to_iterate);
220
6.56M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>*)
Line
Count
Source
218
3.12M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
3.12M
      set_to_list(list_to_iterate);
220
3.12M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
218
193M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
193M
      set_to_list(list_to_iterate);
220
193M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Line
Count
Source
218
933k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
933k
      set_to_list(list_to_iterate);
220
933k
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
Line
Count
Source
218
337k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
337k
      set_to_list(list_to_iterate);
220
337k
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::PARA>*)
Line
Count
Source
218
17.2k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
17.2k
      set_to_list(list_to_iterate);
220
17.2k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
Line
Count
Source
218
13.7M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
13.7M
      set_to_list(list_to_iterate);
220
13.7M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::WERD_RES>*)
Line
Count
Source
218
405k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
405k
      set_to_list(list_to_iterate);
220
405k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>*)
Line
Count
Source
218
19.1k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
19.1k
      set_to_list(list_to_iterate);
220
19.1k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ROW_RES>*)
Line
Count
Source
218
322k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
322k
      set_to_list(list_to_iterate);
220
322k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ColSegment>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::TabConstraint>*)
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>*)
Line
Count
Source
218
72.0M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
72.0M
      set_to_list(list_to_iterate);
220
72.0M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>*)
Line
Count
Source
218
282k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
282k
      set_to_list(list_to_iterate);
220
282k
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::FPSEGPT>*)
Line
Count
Source
218
138k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
138k
      set_to_list(list_to_iterate);
220
138k
    }
221
    /***********************************************************************
222
   *                          ELIST_ITERATOR::set_to_list
223
   *
224
   *  (Re-)initialise the iterator to point to the start of the list_to_iterate
225
   *  over.
226
   **********************************************************************/
227
    void set_to_list( // change list
228
502M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
502M
      list = list_to_iterate;
236
502M
      prev = list->last;
237
502M
      current = list->First();
238
502M
      next = current ? current->next : nullptr;
239
502M
      cycle_pt = nullptr; // await explicit set
240
502M
      started_cycling = false;
241
502M
      ex_current_was_last = false;
242
502M
      ex_current_was_cycle_pt = false;
243
502M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
Line
Count
Source
228
134k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
134k
      list = list_to_iterate;
236
134k
      prev = list->last;
237
134k
      current = list->First();
238
134k
      next = current ? current->next : nullptr;
239
134k
      cycle_pt = nullptr; // await explicit set
240
134k
      started_cycling = false;
241
134k
      ex_current_was_last = false;
242
134k
      ex_current_was_cycle_pt = false;
243
134k
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
228
215M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
215M
      list = list_to_iterate;
236
215M
      prev = list->last;
237
215M
      current = list->First();
238
215M
      next = current ? current->next : nullptr;
239
215M
      cycle_pt = nullptr; // await explicit set
240
215M
      started_cycling = false;
241
215M
      ex_current_was_last = false;
242
215M
      ex_current_was_cycle_pt = false;
243
215M
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
Line
Count
Source
228
16.1M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
16.1M
      list = list_to_iterate;
236
16.1M
      prev = list->last;
237
16.1M
      current = list->First();
238
16.1M
      next = current ? current->next : nullptr;
239
16.1M
      cycle_pt = nullptr; // await explicit set
240
16.1M
      started_cycling = false;
241
16.1M
      ex_current_was_last = false;
242
16.1M
      ex_current_was_cycle_pt = false;
243
16.1M
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ROW>*)
Line
Count
Source
228
102k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
102k
      list = list_to_iterate;
236
102k
      prev = list->last;
237
102k
      current = list->First();
238
102k
      next = current ? current->next : nullptr;
239
102k
      cycle_pt = nullptr; // await explicit set
240
102k
      started_cycling = false;
241
102k
      ex_current_was_last = false;
242
102k
      ex_current_was_cycle_pt = false;
243
102k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
228
14.7M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
14.7M
      list = list_to_iterate;
236
14.7M
      prev = list->last;
237
14.7M
      current = list->First();
238
14.7M
      next = current ? current->next : nullptr;
239
14.7M
      cycle_pt = nullptr; // await explicit set
240
14.7M
      started_cycling = false;
241
14.7M
      ex_current_was_last = false;
242
14.7M
      ex_current_was_cycle_pt = false;
243
14.7M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>*)
Line
Count
Source
228
42.7M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
42.7M
      list = list_to_iterate;
236
42.7M
      prev = list->last;
237
42.7M
      current = list->First();
238
42.7M
      next = current ? current->next : nullptr;
239
42.7M
      cycle_pt = nullptr; // await explicit set
240
42.7M
      started_cycling = false;
241
42.7M
      ex_current_was_last = false;
242
42.7M
      ex_current_was_cycle_pt = false;
243
42.7M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::AmbigSpec>*)
Line
Count
Source
228
6.56M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
6.56M
      list = list_to_iterate;
236
6.56M
      prev = list->last;
237
6.56M
      current = list->First();
238
6.56M
      next = current ? current->next : nullptr;
239
6.56M
      cycle_pt = nullptr; // await explicit set
240
6.56M
      started_cycling = false;
241
6.56M
      ex_current_was_last = false;
242
6.56M
      ex_current_was_cycle_pt = false;
243
6.56M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>*)
Line
Count
Source
228
3.12M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
3.12M
      list = list_to_iterate;
236
3.12M
      prev = list->last;
237
3.12M
      current = list->First();
238
3.12M
      next = current ? current->next : nullptr;
239
3.12M
      cycle_pt = nullptr; // await explicit set
240
3.12M
      started_cycling = false;
241
3.12M
      ex_current_was_last = false;
242
3.12M
      ex_current_was_cycle_pt = false;
243
3.12M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Line
Count
Source
228
1.68M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
1.68M
      list = list_to_iterate;
236
1.68M
      prev = list->last;
237
1.68M
      current = list->First();
238
1.68M
      next = current ? current->next : nullptr;
239
1.68M
      cycle_pt = nullptr; // await explicit set
240
1.68M
      started_cycling = false;
241
1.68M
      ex_current_was_last = false;
242
1.68M
      ex_current_was_cycle_pt = false;
243
1.68M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
Line
Count
Source
228
433k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
433k
      list = list_to_iterate;
236
433k
      prev = list->last;
237
433k
      current = list->First();
238
433k
      next = current ? current->next : nullptr;
239
433k
      cycle_pt = nullptr; // await explicit set
240
433k
      started_cycling = false;
241
433k
      ex_current_was_last = false;
242
433k
      ex_current_was_cycle_pt = false;
243
433k
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::PARA>*)
Line
Count
Source
228
17.2k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
17.2k
      list = list_to_iterate;
236
17.2k
      prev = list->last;
237
17.2k
      current = list->First();
238
17.2k
      next = current ? current->next : nullptr;
239
17.2k
      cycle_pt = nullptr; // await explicit set
240
17.2k
      started_cycling = false;
241
17.2k
      ex_current_was_last = false;
242
17.2k
      ex_current_was_cycle_pt = false;
243
17.2k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>*)
Line
Count
Source
228
7.32M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
7.32M
      list = list_to_iterate;
236
7.32M
      prev = list->last;
237
7.32M
      current = list->First();
238
7.32M
      next = current ? current->next : nullptr;
239
7.32M
      cycle_pt = nullptr; // await explicit set
240
7.32M
      started_cycling = false;
241
7.32M
      ex_current_was_last = false;
242
7.32M
      ex_current_was_cycle_pt = false;
243
7.32M
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ROW_RES>*)
Line
Count
Source
228
7.62M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
7.62M
      list = list_to_iterate;
236
7.62M
      prev = list->last;
237
7.62M
      current = list->First();
238
7.62M
      next = current ? current->next : nullptr;
239
7.62M
      cycle_pt = nullptr; // await explicit set
240
7.62M
      started_cycling = false;
241
7.62M
      ex_current_was_last = false;
242
7.62M
      ex_current_was_cycle_pt = false;
243
7.62M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::WERD_RES>*)
Line
Count
Source
228
85.9M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
85.9M
      list = list_to_iterate;
236
85.9M
      prev = list->last;
237
85.9M
      current = list->First();
238
85.9M
      next = current ? current->next : nullptr;
239
85.9M
      cycle_pt = nullptr; // await explicit set
240
85.9M
      started_cycling = false;
241
85.9M
      ex_current_was_last = false;
242
85.9M
      ex_current_was_cycle_pt = false;
243
85.9M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ColSegment>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::TabConstraint>*)
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>*)
Line
Count
Source
228
99.6M
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
99.6M
      list = list_to_iterate;
236
99.6M
      prev = list->last;
237
99.6M
      current = list->First();
238
99.6M
      next = current ? current->next : nullptr;
239
99.6M
      cycle_pt = nullptr; // await explicit set
240
99.6M
      started_cycling = false;
241
99.6M
      ex_current_was_last = false;
242
99.6M
      ex_current_was_cycle_pt = false;
243
99.6M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>*)
Line
Count
Source
228
282k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
282k
      list = list_to_iterate;
236
282k
      prev = list->last;
237
282k
      current = list->First();
238
282k
      next = current ? current->next : nullptr;
239
282k
      cycle_pt = nullptr; // await explicit set
240
282k
      started_cycling = false;
241
282k
      ex_current_was_last = false;
242
282k
      ex_current_was_cycle_pt = false;
243
282k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>*)
Line
Count
Source
228
202k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
202k
      list = list_to_iterate;
236
202k
      prev = list->last;
237
202k
      current = list->First();
238
202k
      next = current ? current->next : nullptr;
239
202k
      cycle_pt = nullptr; // await explicit set
240
202k
      started_cycling = false;
241
202k
      ex_current_was_last = false;
242
202k
      ex_current_was_cycle_pt = false;
243
202k
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::FPSEGPT>*)
Line
Count
Source
228
207k
      IntrusiveForwardList *list_to_iterate) {
229
#ifndef NDEBUG
230
      if (!list_to_iterate) {
231
        BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
232
      }
233
#endif
234
235
207k
      list = list_to_iterate;
236
207k
      prev = list->last;
237
207k
      current = list->First();
238
207k
      next = current ? current->next : nullptr;
239
207k
      cycle_pt = nullptr; // await explicit set
240
207k
      started_cycling = false;
241
207k
      ex_current_was_last = false;
242
207k
      ex_current_was_cycle_pt = false;
243
207k
    }
244
    /***********************************************************************
245
   *                          ELIST_ITERATOR::add_after_then_move
246
   *
247
   *  Add a new element to the list after the current element and move the
248
   *  iterator to the new element.
249
   **********************************************************************/
250
    void add_after_then_move(  // add after current &
251
21.8M
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
21.8M
      if (list->empty()) {
265
5.15M
        new_element->next = new_element;
266
5.15M
        list->last = new_element;
267
5.15M
        prev = next = new_element;
268
16.6M
      } else {
269
16.6M
        new_element->next = next;
270
271
16.6M
        if (current) { // not extracted
272
16.6M
          current->next = new_element;
273
16.6M
          prev = current;
274
16.6M
          if (current == list->last) {
275
15.7M
            list->last = new_element;
276
15.7M
          }
277
16.6M
        } else { // current extracted
278
810
          prev->next = new_element;
279
810
          if (ex_current_was_last) {
280
468
            list->last = new_element;
281
468
          }
282
810
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
810
        }
286
16.6M
      }
287
21.8M
      current = new_element;
288
21.8M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_after_then_move(tesseract::C_OUTLINE*)
Line
Count
Source
251
7.78M
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
7.78M
      if (list->empty()) {
265
3.88M
        new_element->next = new_element;
266
3.88M
        list->last = new_element;
267
3.88M
        prev = next = new_element;
268
3.90M
      } else {
269
3.90M
        new_element->next = next;
270
271
3.90M
        if (current) { // not extracted
272
3.90M
          current->next = new_element;
273
3.90M
          prev = current;
274
3.90M
          if (current == list->last) {
275
3.87M
            list->last = new_element;
276
3.87M
          }
277
3.90M
        } else { // current extracted
278
810
          prev->next = new_element;
279
810
          if (ex_current_was_last) {
280
468
            list->last = new_element;
281
468
          }
282
810
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
810
        }
286
3.90M
      }
287
7.78M
      current = new_element;
288
7.78M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_after_then_move(tesseract::ICOORDELT*)
Line
Count
Source
251
948k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
948k
      if (list->empty()) {
265
90.8k
        new_element->next = new_element;
266
90.8k
        list->last = new_element;
267
90.8k
        prev = next = new_element;
268
858k
      } else {
269
858k
        new_element->next = next;
270
271
858k
        if (current) { // not extracted
272
858k
          current->next = new_element;
273
858k
          prev = current;
274
858k
          if (current == list->last) {
275
858k
            list->last = new_element;
276
858k
          }
277
858k
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
858k
      }
287
948k
      current = new_element;
288
948k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::add_after_then_move(tesseract::PARA*)
Line
Count
Source
251
24.9k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
24.9k
      if (list->empty()) {
265
17.2k
        new_element->next = new_element;
266
17.2k
        list->last = new_element;
267
17.2k
        prev = next = new_element;
268
17.2k
      } else {
269
7.72k
        new_element->next = next;
270
271
7.72k
        if (current) { // not extracted
272
7.72k
          current->next = new_element;
273
7.72k
          prev = current;
274
7.72k
          if (current == list->last) {
275
7.72k
            list->last = new_element;
276
7.72k
          }
277
7.72k
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
7.72k
      }
287
24.9k
      current = new_element;
288
24.9k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_after_then_move(tesseract::C_BLOB*)
Line
Count
Source
251
5.99M
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
5.99M
      if (list->empty()) {
265
845k
        new_element->next = new_element;
266
845k
        list->last = new_element;
267
845k
        prev = next = new_element;
268
5.15M
      } else {
269
5.15M
        new_element->next = next;
270
271
5.15M
        if (current) { // not extracted
272
5.15M
          current->next = new_element;
273
5.15M
          prev = current;
274
5.15M
          if (current == list->last) {
275
5.11M
            list->last = new_element;
276
5.11M
          }
277
5.15M
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
5.15M
      }
287
5.99M
      current = new_element;
288
5.99M
    } // move to new
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_after_then_move(tesseract::WERD_RES*)
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_after_then_move(tesseract::WERD_CHOICE*)
Line
Count
Source
251
601k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
601k
      if (list->empty()) {
265
27.2k
        new_element->next = new_element;
266
27.2k
        list->last = new_element;
267
27.2k
        prev = next = new_element;
268
574k
      } else {
269
574k
        new_element->next = next;
270
271
574k
        if (current) { // not extracted
272
574k
          current->next = new_element;
273
574k
          prev = current;
274
574k
          if (current == list->last) {
275
574k
            list->last = new_element;
276
574k
          }
277
574k
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
574k
      }
287
601k
      current = new_element;
288
601k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_after_then_move(tesseract::BLOBNBOX*)
Line
Count
Source
251
6.03M
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
6.03M
      if (list->empty()) {
265
62.0k
        new_element->next = new_element;
266
62.0k
        list->last = new_element;
267
62.0k
        prev = next = new_element;
268
5.97M
      } else {
269
5.97M
        new_element->next = next;
270
271
5.97M
        if (current) { // not extracted
272
5.97M
          current->next = new_element;
273
5.97M
          prev = current;
274
5.97M
          if (current == list->last) {
275
5.14M
            list->last = new_element;
276
5.14M
          }
277
5.97M
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
5.97M
      }
287
6.03M
      current = new_element;
288
6.03M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_after_then_move(tesseract::BLOB_CHOICE*)
Line
Count
Source
251
192k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
192k
      if (list->empty()) {
265
192k
        new_element->next = new_element;
266
192k
        list->last = new_element;
267
192k
        prev = next = new_element;
268
192k
      } else {
269
0
        new_element->next = next;
270
271
0
        if (current) { // not extracted
272
0
          current->next = new_element;
273
0
          prev = current;
274
0
          if (current == list->last) {
275
0
            list->last = new_element;
276
0
          }
277
0
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
0
      }
287
192k
      current = new_element;
288
192k
    } // move to new
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::add_after_then_move(tesseract::ColSegment*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::add_after_then_move(tesseract::WorkingPartSet*)
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_after_then_move(tesseract::TO_BLOCK*)
Line
Count
Source
251
19.1k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
19.1k
      if (list->empty()) {
265
19.1k
        new_element->next = new_element;
266
19.1k
        list->last = new_element;
267
19.1k
        prev = next = new_element;
268
19.1k
      } else {
269
0
        new_element->next = next;
270
271
0
        if (current) { // not extracted
272
0
          current->next = new_element;
273
0
          prev = current;
274
0
          if (current == list->last) {
275
0
            list->last = new_element;
276
0
          }
277
0
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
0
      }
287
19.1k
      current = new_element;
288
19.1k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::add_after_then_move(tesseract::ROW*)
Line
Count
Source
251
202k
      T *new_element) {
252
#ifndef NDEBUG
253
      if (!list) {
254
        NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT);
255
      }
256
      if (!new_element) {
257
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
258
      }
259
      if (new_element->next) {
260
        STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT);
261
      }
262
#endif
263
264
202k
      if (list->empty()) {
265
18.6k
        new_element->next = new_element;
266
18.6k
        list->last = new_element;
267
18.6k
        prev = next = new_element;
268
184k
      } else {
269
184k
        new_element->next = next;
270
271
184k
        if (current) { // not extracted
272
184k
          current->next = new_element;
273
184k
          prev = current;
274
184k
          if (current == list->last) {
275
184k
            list->last = new_element;
276
184k
          }
277
184k
        } else { // current extracted
278
0
          prev->next = new_element;
279
0
          if (ex_current_was_last) {
280
0
            list->last = new_element;
281
0
          }
282
0
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
0
        }
286
184k
      }
287
202k
      current = new_element;
288
202k
    } // move to new
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::add_after_then_move(tesseract::FPSEGPT*)
289
      /***********************************************************************
290
     *                          ELIST_ITERATOR::add_after_stay_put
291
     *
292
     *  Add a new element to the list after the current element but do not move
293
     *  the iterator to the new element.
294
     **********************************************************************/
295
    void add_after_stay_put(   // add after current &
296
21.9M
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
21.9M
      if (list->empty()) {
310
19.0M
        new_element->next = new_element;
311
19.0M
        list->last = new_element;
312
19.0M
        prev = next = new_element;
313
19.0M
        ex_current_was_last = false;
314
19.0M
        current = nullptr;
315
19.0M
      } else {
316
2.93M
        new_element->next = next;
317
318
2.93M
        if (current) { // not extracted
319
2.93M
          current->next = new_element;
320
2.93M
          if (prev == current) {
321
2.34M
            prev = new_element;
322
2.34M
          }
323
2.93M
          if (current == list->last) {
324
2.70M
            list->last = new_element;
325
2.70M
          }
326
2.93M
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
2.93M
        next = new_element;
334
2.93M
      }
335
21.9M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_after_stay_put(tesseract::C_BLOB*)
Line
Count
Source
296
135k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
135k
      if (list->empty()) {
310
135k
        new_element->next = new_element;
311
135k
        list->last = new_element;
312
135k
        prev = next = new_element;
313
135k
        ex_current_was_last = false;
314
135k
        current = nullptr;
315
135k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
135k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_after_stay_put(tesseract::BLOCK*)
Line
Count
Source
296
19.1k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
19.1k
      if (list->empty()) {
310
19.1k
        new_element->next = new_element;
311
19.1k
        list->last = new_element;
312
19.1k
        prev = next = new_element;
313
19.1k
        ex_current_was_last = false;
314
19.1k
        current = nullptr;
315
19.1k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
19.1k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_after_stay_put(tesseract::WERD_RES*)
Line
Count
Source
296
160k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
160k
      if (list->empty()) {
310
160k
        new_element->next = new_element;
311
160k
        list->last = new_element;
312
160k
        prev = next = new_element;
313
160k
        ex_current_was_last = false;
314
160k
        current = nullptr;
315
160k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
160k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_after_stay_put(tesseract::BLOBNBOX*)
Line
Count
Source
296
1.46M
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
1.46M
      if (list->empty()) {
310
853k
        new_element->next = new_element;
311
853k
        list->last = new_element;
312
853k
        prev = next = new_element;
313
853k
        ex_current_was_last = false;
314
853k
        current = nullptr;
315
853k
      } else {
316
609k
        new_element->next = next;
317
318
609k
        if (current) { // not extracted
319
609k
          current->next = new_element;
320
609k
          if (prev == current) {
321
358k
            prev = new_element;
322
358k
          }
323
609k
          if (current == list->last) {
324
371k
            list->last = new_element;
325
371k
          }
326
609k
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
609k
        next = new_element;
334
609k
      }
335
1.46M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_after_stay_put(tesseract::C_OUTLINE*)
Line
Count
Source
296
8.07M
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
8.07M
      if (list->empty()) {
310
7.46M
        new_element->next = new_element;
311
7.46M
        list->last = new_element;
312
7.46M
        prev = next = new_element;
313
7.46M
        ex_current_was_last = false;
314
7.46M
        current = nullptr;
315
7.46M
      } else {
316
611k
        new_element->next = next;
317
318
611k
        if (current) { // not extracted
319
611k
          current->next = new_element;
320
611k
          if (prev == current) {
321
611k
            prev = new_element;
322
611k
          }
323
611k
          if (current == list->last) {
324
611k
            list->last = new_element;
325
611k
          }
326
611k
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
611k
        next = new_element;
334
611k
      }
335
8.07M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_after_stay_put(tesseract::ICOORDELT*)
Line
Count
Source
296
647k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
647k
      if (list->empty()) {
310
647k
        new_element->next = new_element;
311
647k
        list->last = new_element;
312
647k
        prev = next = new_element;
313
647k
        ex_current_was_last = false;
314
647k
        current = nullptr;
315
647k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
647k
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::add_after_stay_put(tesseract::ROW*)
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::add_after_stay_put(tesseract::BLOCK_RES*)
Line
Count
Source
296
17.2k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
17.2k
      if (list->empty()) {
310
17.2k
        new_element->next = new_element;
311
17.2k
        list->last = new_element;
312
17.2k
        prev = next = new_element;
313
17.2k
        ex_current_was_last = false;
314
17.2k
        current = nullptr;
315
17.2k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
17.2k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::add_after_stay_put(tesseract::ROW_RES*)
Line
Count
Source
296
17.2k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
17.2k
      if (list->empty()) {
310
17.2k
        new_element->next = new_element;
311
17.2k
        list->last = new_element;
312
17.2k
        prev = next = new_element;
313
17.2k
        ex_current_was_last = false;
314
17.2k
        current = nullptr;
315
17.2k
      } else {
316
0
        new_element->next = next;
317
318
0
        if (current) { // not extracted
319
0
          current->next = new_element;
320
0
          if (prev == current) {
321
0
            prev = new_element;
322
0
          }
323
0
          if (current == list->last) {
324
0
            list->last = new_element;
325
0
          }
326
0
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
0
        next = new_element;
334
0
      }
335
17.2k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_after_stay_put(tesseract::WERD_CHOICE*)
Line
Count
Source
296
346k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
346k
      if (list->empty()) {
310
299k
        new_element->next = new_element;
311
299k
        list->last = new_element;
312
299k
        prev = next = new_element;
313
299k
        ex_current_was_last = false;
314
299k
        current = nullptr;
315
299k
      } else {
316
47.0k
        new_element->next = next;
317
318
47.0k
        if (current) { // not extracted
319
47.0k
          current->next = new_element;
320
47.0k
          if (prev == current) {
321
47.0k
            prev = new_element;
322
47.0k
          }
323
47.0k
          if (current == list->last) {
324
47.0k
            list->last = new_element;
325
47.0k
          }
326
47.0k
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
47.0k
        next = new_element;
334
47.0k
      }
335
346k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_after_stay_put(tesseract::BLOB_CHOICE*)
Line
Count
Source
296
10.6M
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
10.6M
      if (list->empty()) {
310
9.29M
        new_element->next = new_element;
311
9.29M
        list->last = new_element;
312
9.29M
        prev = next = new_element;
313
9.29M
        ex_current_was_last = false;
314
9.29M
        current = nullptr;
315
9.29M
      } else {
316
1.31M
        new_element->next = next;
317
318
1.31M
        if (current) { // not extracted
319
1.31M
          current->next = new_element;
320
1.31M
          if (prev == current) {
321
1.26M
            prev = new_element;
322
1.26M
          }
323
1.31M
          if (current == list->last) {
324
1.31M
            list->last = new_element;
325
1.31M
          }
326
1.31M
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
1.31M
        next = new_element;
334
1.31M
      }
335
10.6M
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_after_stay_put(tesseract::TO_BLOCK*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::add_after_stay_put(tesseract::TabConstraint*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::add_after_stay_put(tesseract::ViterbiStateEntry*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::add_after_stay_put(tesseract::AmbigSpec*)
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::add_after_stay_put(tesseract::C_OUTLINE_FRAG*)
Line
Count
Source
296
97.7k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
97.7k
      if (list->empty()) {
310
60.5k
        new_element->next = new_element;
311
60.5k
        list->last = new_element;
312
60.5k
        prev = next = new_element;
313
60.5k
        ex_current_was_last = false;
314
60.5k
        current = nullptr;
315
60.5k
      } else {
316
37.1k
        new_element->next = next;
317
318
37.1k
        if (current) { // not extracted
319
37.1k
          current->next = new_element;
320
37.1k
          if (prev == current) {
321
37.1k
            prev = new_element;
322
37.1k
          }
323
37.1k
          if (current == list->last) {
324
37.1k
            list->last = new_element;
325
37.1k
          }
326
37.1k
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
37.1k
        next = new_element;
334
37.1k
      }
335
97.7k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::add_after_stay_put(tesseract::SORTED_FLOAT*)
Line
Count
Source
296
394k
      T *new_element) {
297
#ifndef NDEBUG
298
      if (!list) {
299
        NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
300
      }
301
      if (!new_element) {
302
        BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
303
      }
304
      if (new_element->next) {
305
        STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT);
306
      }
307
#endif
308
309
394k
      if (list->empty()) {
310
75.9k
        new_element->next = new_element;
311
75.9k
        list->last = new_element;
312
75.9k
        prev = next = new_element;
313
75.9k
        ex_current_was_last = false;
314
75.9k
        current = nullptr;
315
318k
      } else {
316
318k
        new_element->next = next;
317
318
318k
        if (current) { // not extracted
319
318k
          current->next = new_element;
320
318k
          if (prev == current) {
321
27.7k
            prev = new_element;
322
27.7k
          }
323
318k
          if (current == list->last) {
324
318k
            list->last = new_element;
325
318k
          }
326
318k
        } else { // current extracted
327
0
          prev->next = new_element;
328
0
          if (ex_current_was_last) {
329
0
            list->last = new_element;
330
0
            ex_current_was_last = false;
331
0
          }
332
0
        }
333
318k
        next = new_element;
334
318k
      }
335
394k
    } // stay at current
336
      /***********************************************************************
337
     *                          ELIST_ITERATOR::add_before_then_move
338
     *
339
     *  Add a new element to the list before the current element and move the
340
     *  iterator to the new element.
341
     **********************************************************************/
342
    void add_before_then_move( // add before current &
343
5.45M
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
5.45M
      if (list->empty()) {
357
71.0k
        new_element->next = new_element;
358
71.0k
        list->last = new_element;
359
71.0k
        prev = next = new_element;
360
5.38M
      } else {
361
5.38M
        prev->next = new_element;
362
5.38M
        if (current) { // not extracted
363
5.38M
          new_element->next = current;
364
5.38M
          next = current;
365
5.38M
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
5.38M
      }
375
5.45M
      current = new_element;
376
5.45M
    } // move to new
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_before_then_move(tesseract::WERD_RES*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_before_then_move(tesseract::BLOBNBOX*)
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_before_then_move(tesseract::BLOB_CHOICE*)
Line
Count
Source
343
1.92k
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
1.92k
      if (list->empty()) {
357
1.70k
        new_element->next = new_element;
358
1.70k
        list->last = new_element;
359
1.70k
        prev = next = new_element;
360
1.70k
      } else {
361
226
        prev->next = new_element;
362
226
        if (current) { // not extracted
363
226
          new_element->next = current;
364
226
          next = current;
365
226
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
226
      }
375
1.92k
      current = new_element;
376
1.92k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::add_before_then_move(tesseract::ViterbiStateEntry*)
Line
Count
Source
343
4.40M
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
4.40M
      if (list->empty()) {
357
0
        new_element->next = new_element;
358
0
        list->last = new_element;
359
0
        prev = next = new_element;
360
4.40M
      } else {
361
4.40M
        prev->next = new_element;
362
4.40M
        if (current) { // not extracted
363
4.40M
          new_element->next = current;
364
4.40M
          next = current;
365
4.40M
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
4.40M
      }
375
4.40M
      current = new_element;
376
4.40M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::add_before_then_move(tesseract::AmbigSpec*)
Line
Count
Source
343
74.3k
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
74.3k
      if (list->empty()) {
357
0
        new_element->next = new_element;
358
0
        list->last = new_element;
359
0
        prev = next = new_element;
360
74.3k
      } else {
361
74.3k
        prev->next = new_element;
362
74.3k
        if (current) { // not extracted
363
74.3k
          new_element->next = current;
364
74.3k
          next = current;
365
74.3k
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
74.3k
      }
375
74.3k
      current = new_element;
376
74.3k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::add_before_then_move(tesseract::C_OUTLINE_FRAG*)
Line
Count
Source
343
90.6k
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
90.6k
      if (list->empty()) {
357
0
        new_element->next = new_element;
358
0
        list->last = new_element;
359
0
        prev = next = new_element;
360
90.6k
      } else {
361
90.6k
        prev->next = new_element;
362
90.6k
        if (current) { // not extracted
363
90.6k
          new_element->next = current;
364
90.6k
          next = current;
365
90.6k
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
90.6k
      }
375
90.6k
      current = new_element;
376
90.6k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::add_before_then_move(tesseract::FPSEGPT*)
Line
Count
Source
343
879k
      T *new_element) {
344
#ifndef NDEBUG
345
      if (!list) {
346
        NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT);
347
      }
348
      if (!new_element) {
349
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
350
      }
351
      if (new_element->next) {
352
        STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT);
353
      }
354
#endif
355
356
879k
      if (list->empty()) {
357
69.3k
        new_element->next = new_element;
358
69.3k
        list->last = new_element;
359
69.3k
        prev = next = new_element;
360
810k
      } else {
361
810k
        prev->next = new_element;
362
810k
        if (current) { // not extracted
363
810k
          new_element->next = current;
364
810k
          next = current;
365
810k
        } else { // current extracted
366
0
          new_element->next = next;
367
0
          if (ex_current_was_last) {
368
0
            list->last = new_element;
369
0
          }
370
0
          if (ex_current_was_cycle_pt) {
371
0
            cycle_pt = new_element;
372
0
          }
373
0
        }
374
810k
      }
375
879k
      current = new_element;
376
879k
    } // move to new
377
      /***********************************************************************
378
     *                          ELIST_ITERATOR::add_before_stay_put
379
     *
380
     *  Add a new element to the list before the current element but don't move the
381
     *  iterator to the new element.
382
     **********************************************************************/
383
    void add_before_stay_put(  // add before current &
384
25.8M
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
25.8M
      if (list->empty()) {
398
20.9k
        new_element->next = new_element;
399
20.9k
        list->last = new_element;
400
20.9k
        prev = next = new_element;
401
20.9k
        ex_current_was_last = true;
402
20.9k
        current = nullptr;
403
25.8M
      } else {
404
25.8M
        prev->next = new_element;
405
25.8M
        if (current) { // not extracted
406
8.95M
          new_element->next = current;
407
8.95M
          if (next == current) {
408
90.1k
            next = new_element;
409
90.1k
          }
410
16.8M
        } else { // current extracted
411
16.8M
          new_element->next = next;
412
16.8M
          if (ex_current_was_last) {
413
2.16k
            list->last = new_element;
414
2.16k
          }
415
16.8M
        }
416
25.8M
        prev = new_element;
417
25.8M
      }
418
25.8M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_before_stay_put(tesseract::C_BLOB*)
Line
Count
Source
384
504k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
504k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
504k
      } else {
404
504k
        prev->next = new_element;
405
504k
        if (current) { // not extracted
406
0
          new_element->next = current;
407
0
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
504k
        } else { // current extracted
411
504k
          new_element->next = next;
412
504k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
504k
        }
416
504k
        prev = new_element;
417
504k
      }
418
504k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_before_stay_put(tesseract::BLOB_CHOICE*)
Line
Count
Source
384
8.46M
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
8.46M
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
8.46M
      } else {
404
8.46M
        prev->next = new_element;
405
8.46M
        if (current) { // not extracted
406
1.11M
          new_element->next = current;
407
1.11M
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
7.35M
        } else { // current extracted
411
7.35M
          new_element->next = next;
412
7.35M
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
7.35M
        }
416
8.46M
        prev = new_element;
417
8.46M
      }
418
8.46M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_before_stay_put(tesseract::C_OUTLINE*)
Line
Count
Source
384
2.35M
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
2.35M
      if (list->empty()) {
398
20.9k
        new_element->next = new_element;
399
20.9k
        list->last = new_element;
400
20.9k
        prev = next = new_element;
401
20.9k
        ex_current_was_last = true;
402
20.9k
        current = nullptr;
403
2.33M
      } else {
404
2.33M
        prev->next = new_element;
405
2.33M
        if (current) { // not extracted
406
2.27M
          new_element->next = current;
407
2.27M
          if (next == current) {
408
621
            next = new_element;
409
621
          }
410
2.27M
        } else { // current extracted
411
63.9k
          new_element->next = next;
412
63.9k
          if (ex_current_was_last) {
413
2.16k
            list->last = new_element;
414
2.16k
          }
415
63.9k
        }
416
2.33M
        prev = new_element;
417
2.33M
      }
418
2.35M
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_before_stay_put(tesseract::BLOCK*)
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_before_stay_put(tesseract::WERD_RES*)
Line
Count
Source
384
352k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
352k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
352k
      } else {
404
352k
        prev->next = new_element;
405
352k
        if (current) { // not extracted
406
142k
          new_element->next = current;
407
142k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
209k
        } else { // current extracted
411
209k
          new_element->next = next;
412
209k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
209k
        }
416
352k
        prev = new_element;
417
352k
      }
418
352k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_before_stay_put(tesseract::BLOBNBOX*)
Line
Count
Source
384
11.7M
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
11.7M
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
11.7M
      } else {
404
11.7M
        prev->next = new_element;
405
11.7M
        if (current) { // not extracted
406
3.79M
          new_element->next = current;
407
3.79M
          if (next == current) {
408
155
            next = new_element;
409
155
          }
410
7.94M
        } else { // current extracted
411
7.94M
          new_element->next = next;
412
7.94M
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
7.94M
        }
416
11.7M
        prev = new_element;
417
11.7M
      }
418
11.7M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_before_stay_put(tesseract::ICOORDELT*)
Line
Count
Source
384
753k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
753k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
753k
      } else {
404
753k
        prev->next = new_element;
405
753k
        if (current) { // not extracted
406
76.7k
          new_element->next = current;
407
76.7k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
677k
        } else { // current extracted
411
677k
          new_element->next = next;
412
677k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
677k
        }
416
753k
        prev = new_element;
417
753k
      }
418
753k
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::add_before_stay_put(tesseract::ROW*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::add_before_stay_put(tesseract::BLOCK_RES*)
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::add_before_stay_put(tesseract::ROW_RES*)
Line
Count
Source
384
143k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
143k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
143k
      } else {
404
143k
        prev->next = new_element;
405
143k
        if (current) { // not extracted
406
0
          new_element->next = current;
407
0
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
143k
        } else { // current extracted
411
143k
          new_element->next = next;
412
143k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
143k
        }
416
143k
        prev = new_element;
417
143k
      }
418
143k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_before_stay_put(tesseract::WERD_CHOICE*)
Line
Count
Source
384
572k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
572k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
572k
      } else {
404
572k
        prev->next = new_element;
405
572k
        if (current) { // not extracted
406
572k
          new_element->next = current;
407
572k
          if (next == current) {
408
43.2k
            next = new_element;
409
43.2k
          }
410
572k
        } else { // current extracted
411
0
          new_element->next = next;
412
0
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
0
        }
416
572k
        prev = new_element;
417
572k
      }
418
572k
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_before_stay_put(tesseract::TO_BLOCK*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::add_before_stay_put(tesseract::TabConstraint*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::add_before_stay_put(tesseract::ViterbiStateEntry*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::add_before_stay_put(tesseract::AmbigSpec*)
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::add_before_stay_put(tesseract::C_OUTLINE_FRAG*)
Line
Count
Source
384
33.0k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
33.0k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
33.0k
      } else {
404
33.0k
        prev->next = new_element;
405
33.0k
        if (current) { // not extracted
406
33.0k
          new_element->next = current;
407
33.0k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
33.0k
        } else { // current extracted
411
0
          new_element->next = next;
412
0
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
0
        }
416
33.0k
        prev = new_element;
417
33.0k
      }
418
33.0k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::add_before_stay_put(tesseract::SORTED_FLOAT*)
Line
Count
Source
384
938k
      T *new_element) {
385
#ifndef NDEBUG
386
      if (!list) {
387
        NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
388
      }
389
      if (!new_element) {
390
        BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
391
      }
392
      if (new_element->next) {
393
        STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT);
394
      }
395
#endif
396
397
938k
      if (list->empty()) {
398
0
        new_element->next = new_element;
399
0
        list->last = new_element;
400
0
        prev = next = new_element;
401
0
        ex_current_was_last = true;
402
0
        current = nullptr;
403
938k
      } else {
404
938k
        prev->next = new_element;
405
938k
        if (current) { // not extracted
406
938k
          new_element->next = current;
407
938k
          if (next == current) {
408
46.1k
            next = new_element;
409
46.1k
          }
410
938k
        } else { // current extracted
411
0
          new_element->next = next;
412
0
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
0
        }
416
938k
        prev = new_element;
417
938k
      }
418
938k
    } // stay at current
419
      /***********************************************************************
420
     *                          ELIST_ITERATOR::add_list_after
421
     *
422
     *  Insert another list to this list after the current element but don't move
423
     *the
424
     *  iterator.
425
     **********************************************************************/
426
    void add_list_after(     // add a list &
427
2.55M
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
2.55M
      if (!list_to_add->empty()) {
438
2.51M
        if (list->empty()) {
439
777k
          list->last = list_to_add->last;
440
777k
          prev = list->last;
441
777k
          next = list->First();
442
777k
          ex_current_was_last = true;
443
777k
          current = nullptr;
444
1.73M
        } else {
445
1.73M
          if (current) { // not extracted
446
1.53M
            current->next = list_to_add->First();
447
1.53M
            if (current == list->last) {
448
1.39M
              list->last = list_to_add->last;
449
1.39M
            }
450
1.53M
            list_to_add->last->next = next;
451
1.53M
            next = current->next;
452
1.53M
          } else { // current extracted
453
200k
            prev->next = list_to_add->First();
454
200k
            if (ex_current_was_last) {
455
20.0k
              list->last = list_to_add->last;
456
20.0k
              ex_current_was_last = false;
457
20.0k
            }
458
200k
            list_to_add->last->next = next;
459
200k
            next = prev->next;
460
200k
          }
461
1.73M
        }
462
2.51M
        list_to_add->last = nullptr;
463
2.51M
      }
464
2.55M
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>*)
Line
Count
Source
427
141k
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
141k
      if (!list_to_add->empty()) {
438
138k
        if (list->empty()) {
439
120k
          list->last = list_to_add->last;
440
120k
          prev = list->last;
441
120k
          next = list->First();
442
120k
          ex_current_was_last = true;
443
120k
          current = nullptr;
444
120k
        } else {
445
17.8k
          if (current) { // not extracted
446
17.8k
            current->next = list_to_add->First();
447
17.8k
            if (current == list->last) {
448
17.8k
              list->last = list_to_add->last;
449
17.8k
            }
450
17.8k
            list_to_add->last->next = next;
451
17.8k
            next = current->next;
452
17.8k
          } else { // current extracted
453
0
            prev->next = list_to_add->First();
454
0
            if (ex_current_was_last) {
455
0
              list->last = list_to_add->last;
456
0
              ex_current_was_last = false;
457
0
            }
458
0
            list_to_add->last->next = next;
459
0
            next = prev->next;
460
0
          }
461
17.8k
        }
462
138k
        list_to_add->last = nullptr;
463
138k
      }
464
141k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
427
1.31M
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
1.31M
      if (!list_to_add->empty()) {
438
1.31M
        if (list->empty()) {
439
0
          list->last = list_to_add->last;
440
0
          prev = list->last;
441
0
          next = list->First();
442
0
          ex_current_was_last = true;
443
0
          current = nullptr;
444
1.31M
        } else {
445
1.31M
          if (current) { // not extracted
446
1.31M
            current->next = list_to_add->First();
447
1.31M
            if (current == list->last) {
448
1.31M
              list->last = list_to_add->last;
449
1.31M
            }
450
1.31M
            list_to_add->last->next = next;
451
1.31M
            next = current->next;
452
1.31M
          } else { // current extracted
453
0
            prev->next = list_to_add->First();
454
0
            if (ex_current_was_last) {
455
0
              list->last = list_to_add->last;
456
0
              ex_current_was_last = false;
457
0
            }
458
0
            list_to_add->last->next = next;
459
0
            next = prev->next;
460
0
          }
461
1.31M
        }
462
1.31M
        list_to_add->last = nullptr;
463
1.31M
      }
464
1.31M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
Line
Count
Source
427
422k
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
422k
      if (!list_to_add->empty()) {
438
388k
        if (list->empty()) {
439
34.9k
          list->last = list_to_add->last;
440
34.9k
          prev = list->last;
441
34.9k
          next = list->First();
442
34.9k
          ex_current_was_last = true;
443
34.9k
          current = nullptr;
444
353k
        } else {
445
353k
          if (current) { // not extracted
446
153k
            current->next = list_to_add->First();
447
153k
            if (current == list->last) {
448
10.3k
              list->last = list_to_add->last;
449
10.3k
            }
450
153k
            list_to_add->last->next = next;
451
153k
            next = current->next;
452
200k
          } else { // current extracted
453
200k
            prev->next = list_to_add->First();
454
200k
            if (ex_current_was_last) {
455
20.0k
              list->last = list_to_add->last;
456
20.0k
              ex_current_was_last = false;
457
20.0k
            }
458
200k
            list_to_add->last->next = next;
459
200k
            next = prev->next;
460
200k
          }
461
353k
        }
462
388k
        list_to_add->last = nullptr;
463
388k
      }
464
422k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
427
656k
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
656k
      if (!list_to_add->empty()) {
438
655k
        if (list->empty()) {
439
606k
          list->last = list_to_add->last;
440
606k
          prev = list->last;
441
606k
          next = list->First();
442
606k
          ex_current_was_last = true;
443
606k
          current = nullptr;
444
606k
        } else {
445
48.9k
          if (current) { // not extracted
446
48.9k
            current->next = list_to_add->First();
447
48.9k
            if (current == list->last) {
448
48.9k
              list->last = list_to_add->last;
449
48.9k
            }
450
48.9k
            list_to_add->last->next = next;
451
48.9k
            next = current->next;
452
48.9k
          } else { // current extracted
453
0
            prev->next = list_to_add->First();
454
0
            if (ex_current_was_last) {
455
0
              list->last = list_to_add->last;
456
0
              ex_current_was_last = false;
457
0
            }
458
0
            list_to_add->last->next = next;
459
0
            next = prev->next;
460
0
          }
461
48.9k
        }
462
655k
        list_to_add->last = nullptr;
463
655k
      }
464
656k
    } // stay at current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Line
Count
Source
427
14.9k
      IntrusiveForwardList *list_to_add) {
428
#ifndef NDEBUG
429
      if (!list) {
430
        NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT);
431
      }
432
      if (!list_to_add) {
433
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
434
      }
435
#endif
436
437
14.9k
      if (!list_to_add->empty()) {
438
14.9k
        if (list->empty()) {
439
14.9k
          list->last = list_to_add->last;
440
14.9k
          prev = list->last;
441
14.9k
          next = list->First();
442
14.9k
          ex_current_was_last = true;
443
14.9k
          current = nullptr;
444
14.9k
        } else {
445
0
          if (current) { // not extracted
446
0
            current->next = list_to_add->First();
447
0
            if (current == list->last) {
448
0
              list->last = list_to_add->last;
449
0
            }
450
0
            list_to_add->last->next = next;
451
0
            next = current->next;
452
0
          } else { // current extracted
453
0
            prev->next = list_to_add->First();
454
0
            if (ex_current_was_last) {
455
0
              list->last = list_to_add->last;
456
0
              ex_current_was_last = false;
457
0
            }
458
0
            list_to_add->last->next = next;
459
0
            next = prev->next;
460
0
          }
461
0
        }
462
14.9k
        list_to_add->last = nullptr;
463
14.9k
      }
464
14.9k
    } // stay at current
465
      /***********************************************************************
466
     *                          ELIST_ITERATOR::add_list_before
467
     *
468
     *  Insert another list to this list before the current element. Move the
469
     *  iterator to the start of the inserted elements
470
     *  iterator.
471
     **********************************************************************/
472
    void add_list_before(    // add a list &
473
115k
      IntrusiveForwardList *list_to_add) {
474
#ifndef NDEBUG
475
      if (!list) {
476
        NO_LIST.error("ELIST_ITERATOR::add_list_before", ABORT);
477
      }
478
      if (!list_to_add) {
479
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
480
      }
481
#endif
482
483
115k
      if (!list_to_add->empty()) {
484
95.8k
        if (list->empty()) {
485
28.3k
          list->last = list_to_add->last;
486
28.3k
          prev = list->last;
487
28.3k
          current = list->First();
488
28.3k
          next = current->next;
489
28.3k
          ex_current_was_last = false;
490
67.4k
        } else {
491
67.4k
          prev->next = list_to_add->First();
492
67.4k
          if (current) { // not extracted
493
67.4k
            list_to_add->last->next = current;
494
67.4k
          } else { // current extracted
495
0
            list_to_add->last->next = next;
496
0
            if (ex_current_was_last) {
497
0
              list->last = list_to_add->last;
498
0
            }
499
0
            if (ex_current_was_cycle_pt) {
500
0
              cycle_pt = prev->next;
501
0
            }
502
0
          }
503
67.4k
          current = prev->next;
504
67.4k
          next = current->next;
505
67.4k
        }
506
95.8k
        list_to_add->last = nullptr;
507
95.8k
      }
508
115k
    } // move to it 1st item
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::WERD_RES>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::TabConstraint>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>*)
Line
Count
Source
473
67.4k
      IntrusiveForwardList *list_to_add) {
474
#ifndef NDEBUG
475
      if (!list) {
476
        NO_LIST.error("ELIST_ITERATOR::add_list_before", ABORT);
477
      }
478
      if (!list_to_add) {
479
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
480
      }
481
#endif
482
483
67.4k
      if (!list_to_add->empty()) {
484
67.4k
        if (list->empty()) {
485
0
          list->last = list_to_add->last;
486
0
          prev = list->last;
487
0
          current = list->First();
488
0
          next = current->next;
489
0
          ex_current_was_last = false;
490
67.4k
        } else {
491
67.4k
          prev->next = list_to_add->First();
492
67.4k
          if (current) { // not extracted
493
67.4k
            list_to_add->last->next = current;
494
67.4k
          } else { // current extracted
495
0
            list_to_add->last->next = next;
496
0
            if (ex_current_was_last) {
497
0
              list->last = list_to_add->last;
498
0
            }
499
0
            if (ex_current_was_cycle_pt) {
500
0
              cycle_pt = prev->next;
501
0
            }
502
0
          }
503
67.4k
          current = prev->next;
504
67.4k
          next = current->next;
505
67.4k
        }
506
67.4k
        list_to_add->last = nullptr;
507
67.4k
      }
508
67.4k
    } // move to it 1st item
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
473
48.1k
      IntrusiveForwardList *list_to_add) {
474
#ifndef NDEBUG
475
      if (!list) {
476
        NO_LIST.error("ELIST_ITERATOR::add_list_before", ABORT);
477
      }
478
      if (!list_to_add) {
479
        BAD_PARAMETER.error("ELIST_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
480
      }
481
#endif
482
483
48.1k
      if (!list_to_add->empty()) {
484
28.3k
        if (list->empty()) {
485
28.3k
          list->last = list_to_add->last;
486
28.3k
          prev = list->last;
487
28.3k
          current = list->First();
488
28.3k
          next = current->next;
489
28.3k
          ex_current_was_last = false;
490
28.3k
        } else {
491
0
          prev->next = list_to_add->First();
492
0
          if (current) { // not extracted
493
0
            list_to_add->last->next = current;
494
0
          } else { // current extracted
495
0
            list_to_add->last->next = next;
496
0
            if (ex_current_was_last) {
497
0
              list->last = list_to_add->last;
498
0
            }
499
0
            if (ex_current_was_cycle_pt) {
500
0
              cycle_pt = prev->next;
501
0
            }
502
0
          }
503
0
          current = prev->next;
504
0
          next = current->next;
505
0
        }
506
28.3k
        list_to_add->last = nullptr;
507
28.3k
      }
508
48.1k
    } // move to it 1st item
509
510
2.94G
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
2.94G
      return current;
520
2.94G
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::data()
Line
Count
Source
510
109k
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
109k
      return current;
520
109k
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::data()
Line
Count
Source
510
282M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
282M
      return current;
520
282M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::data()
Line
Count
Source
510
10.6M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
10.6M
      return current;
520
10.6M
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::data()
Line
Count
Source
510
124M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
124M
      return current;
520
124M
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::data()
Line
Count
Source
510
870k
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
870k
      return current;
520
870k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::data()
Line
Count
Source
510
124M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
124M
      return current;
520
124M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::data()
Line
Count
Source
510
244M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
244M
      return current;
520
244M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::data()
Line
Count
Source
510
649M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
649M
      return current;
520
649M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::data()
Line
Count
Source
510
15.4M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
15.4M
      return current;
520
15.4M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::data()
Line
Count
Source
510
517k
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
517k
      return current;
520
517k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::data()
Line
Count
Source
510
127M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
127M
      return current;
520
127M
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::data()
Line
Count
Source
510
211M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
211M
      return current;
520
211M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::data()
Line
Count
Source
510
343M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
343M
      return current;
520
343M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::data()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::data()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::data()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::data()
Line
Count
Source
510
799M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
799M
      return current;
520
799M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::data()
Line
Count
Source
510
929k
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
929k
      return current;
520
929k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::data()
Line
Count
Source
510
7.59M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
7.59M
      return current;
520
7.59M
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::data()
Line
Count
Source
510
1.15M
    T *data() { // get current data
511
#ifndef NDEBUG
512
      if (!list) {
513
        NO_LIST.error("ELIST_ITERATOR::data", ABORT);
514
      }
515
      if (!current) {
516
        NULL_DATA.error("ELIST_ITERATOR::data", ABORT);
517
      }
518
#endif
519
1.15M
      return current;
520
1.15M
    }
521
    /***********************************************************************
522
   *              ELIST_ITERATOR::data_relative
523
   *
524
   *  Return the data pointer to the element "offset" elements from current.
525
   *  "offset" must not be less than -1.
526
   *  (This function can't be INLINEd because it contains a loop)
527
   **********************************************************************/
528
    T *data_relative( // get data + or - ...
529
12.2M
      int8_t offset) {                       // offset from current
530
12.2M
      T *ptr;
531
532
#ifndef NDEBUG
533
      if (!list)
534
        NO_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
535
      if (list->empty())
536
        EMPTY_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
537
      if (offset < -1)
538
        BAD_PARAMETER.error("ELIST_ITERATOR::data_relative", ABORT, "offset < -l");
539
#endif
540
541
12.2M
      if (offset == -1) {
542
8.26M
        ptr = prev;
543
8.26M
      } else {
544
9.85M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
5.83M
          ;
546
5.83M
        }
547
4.01M
      }
548
549
#ifndef NDEBUG
550
      if (!ptr)
551
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
552
#endif
553
554
12.2M
      return ptr;
555
12.2M
    }        // offset from current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::data_relative(signed char)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::data_relative(signed char)
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::data_relative(signed char)
Line
Count
Source
529
14.7k
      int8_t offset) {                       // offset from current
530
14.7k
      T *ptr;
531
532
#ifndef NDEBUG
533
      if (!list)
534
        NO_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
535
      if (list->empty())
536
        EMPTY_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
537
      if (offset < -1)
538
        BAD_PARAMETER.error("ELIST_ITERATOR::data_relative", ABORT, "offset < -l");
539
#endif
540
541
14.7k
      if (offset == -1) {
542
0
        ptr = prev;
543
14.7k
      } else {
544
29.4k
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
14.7k
          ;
546
14.7k
        }
547
14.7k
      }
548
549
#ifndef NDEBUG
550
      if (!ptr)
551
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
552
#endif
553
554
14.7k
      return ptr;
555
14.7k
    }        // offset from current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::data_relative(signed char)
Line
Count
Source
529
3.15M
      int8_t offset) {                       // offset from current
530
3.15M
      T *ptr;
531
532
#ifndef NDEBUG
533
      if (!list)
534
        NO_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
535
      if (list->empty())
536
        EMPTY_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
537
      if (offset < -1)
538
        BAD_PARAMETER.error("ELIST_ITERATOR::data_relative", ABORT, "offset < -l");
539
#endif
540
541
3.15M
      if (offset == -1) {
542
2.82M
        ptr = prev;
543
2.82M
      } else {
544
671k
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
335k
          ;
546
335k
        }
547
335k
      }
548
549
#ifndef NDEBUG
550
      if (!ptr)
551
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
552
#endif
553
554
3.15M
      return ptr;
555
3.15M
    }        // offset from current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::data_relative(signed char)
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::data_relative(signed char)
Line
Count
Source
529
8.19M
      int8_t offset) {                       // offset from current
530
8.19M
      T *ptr;
531
532
#ifndef NDEBUG
533
      if (!list)
534
        NO_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
535
      if (list->empty())
536
        EMPTY_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
537
      if (offset < -1)
538
        BAD_PARAMETER.error("ELIST_ITERATOR::data_relative", ABORT, "offset < -l");
539
#endif
540
541
8.19M
      if (offset == -1) {
542
5.43M
        ptr = prev;
543
5.43M
      } else {
544
5.51M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
2.75M
          ;
546
2.75M
        }
547
2.75M
      }
548
549
#ifndef NDEBUG
550
      if (!ptr)
551
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
552
#endif
553
554
8.19M
      return ptr;
555
8.19M
    }        // offset from current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::data_relative(signed char)
Line
Count
Source
529
911k
      int8_t offset) {                       // offset from current
530
911k
      T *ptr;
531
532
#ifndef NDEBUG
533
      if (!list)
534
        NO_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
535
      if (list->empty())
536
        EMPTY_LIST.error("ELIST_ITERATOR::data_relative", ABORT);
537
      if (offset < -1)
538
        BAD_PARAMETER.error("ELIST_ITERATOR::data_relative", ABORT, "offset < -l");
539
#endif
540
541
911k
      if (offset == -1) {
542
0
        ptr = prev;
543
911k
      } else {
544
3.64M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
2.73M
          ;
546
2.73M
        }
547
911k
      }
548
549
#ifndef NDEBUG
550
      if (!ptr)
551
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
552
#endif
553
554
911k
      return ptr;
555
911k
    }        // offset from current
556
      /***********************************************************************
557
     *              ELIST_ITERATOR::forward
558
     *
559
     *  Move the iterator to the next element of the list.
560
     *  REMEMBER: ALL LISTS ARE CIRCULAR.
561
     **********************************************************************/
562
2.52G
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
2.52G
      if (list->empty()) {
568
7.79M
        return nullptr;
569
7.79M
      }
570
571
2.51G
      if (current) { // not removed so
572
        // set previous
573
2.49G
        prev = current;
574
2.49G
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
2.49G
        current = current->next;
577
2.49G
      } else {
578
25.4M
        if (ex_current_was_cycle_pt) {
579
18.2M
          cycle_pt = next;
580
18.2M
        }
581
25.4M
        current = next;
582
25.4M
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
2.51G
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
2.51G
      return current;
598
2.52G
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::forward()
Line
Count
Source
562
109k
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
109k
      if (list->empty()) {
568
1.97k
        return nullptr;
569
1.97k
      }
570
571
107k
      if (current) { // not removed so
572
        // set previous
573
107k
        prev = current;
574
107k
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
107k
        current = current->next;
577
107k
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
107k
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
107k
      return current;
598
109k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::forward()
Line
Count
Source
562
309M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
309M
      if (list->empty()) {
568
6.82M
        return nullptr;
569
6.82M
      }
570
571
303M
      if (current) { // not removed so
572
        // set previous
573
298M
        prev = current;
574
298M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
298M
        current = current->next;
577
298M
      } else {
578
4.26M
        if (ex_current_was_cycle_pt) {
579
3.66M
          cycle_pt = next;
580
3.66M
        }
581
4.26M
        current = next;
582
4.26M
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
303M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
303M
      return current;
598
309M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::forward()
Line
Count
Source
562
293M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
293M
      if (list->empty()) {
568
349k
        return nullptr;
569
349k
      }
570
571
292M
      if (current) { // not removed so
572
        // set previous
573
276M
        prev = current;
574
276M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
276M
        current = current->next;
577
276M
      } else {
578
15.7M
        if (ex_current_was_cycle_pt) {
579
10.5M
          cycle_pt = next;
580
10.5M
        }
581
15.7M
        current = next;
582
15.7M
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
292M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
292M
      return current;
598
293M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::forward()
Line
Count
Source
562
681k
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
681k
      if (list->empty()) {
568
1.43k
        return nullptr;
569
1.43k
      }
570
571
679k
      if (current) { // not removed so
572
        // set previous
573
638k
        prev = current;
574
638k
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
638k
        current = current->next;
577
638k
      } else {
578
41.0k
        if (ex_current_was_cycle_pt) {
579
13.1k
          cycle_pt = next;
580
13.1k
        }
581
41.0k
        current = next;
582
41.0k
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
679k
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
679k
      return current;
598
681k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::forward()
Line
Count
Source
562
127M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
127M
      if (list->empty()) {
568
301k
        return nullptr;
569
301k
      }
570
571
126M
      if (current) { // not removed so
572
        // set previous
573
122M
        prev = current;
574
122M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
122M
        current = current->next;
577
122M
      } else {
578
4.20M
        if (ex_current_was_cycle_pt) {
579
3.65M
          cycle_pt = next;
580
3.65M
        }
581
4.20M
        current = next;
582
4.20M
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
126M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
126M
      return current;
598
127M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::forward()
Line
Count
Source
562
88.7M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
88.7M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
88.7M
      if (current) { // not removed so
572
        // set previous
573
88.7M
        prev = current;
574
88.7M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
88.7M
        current = current->next;
577
88.7M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
88.7M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
88.7M
      return current;
598
88.7M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::forward()
Line
Count
Source
562
637M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
637M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
637M
      if (current) { // not removed so
572
        // set previous
573
637M
        prev = current;
574
637M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
637M
        current = current->next;
577
637M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
637M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
637M
      return current;
598
637M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::forward()
Line
Count
Source
562
15.2M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
15.2M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
15.2M
      if (current) { // not removed so
572
        // set previous
573
14.7M
        prev = current;
574
14.7M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
14.7M
        current = current->next;
577
14.7M
      } else {
578
475k
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
475k
        current = next;
582
475k
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
15.2M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
15.2M
      return current;
598
15.2M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::forward()
Line
Count
Source
562
3.51M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
3.51M
      if (list->empty()) {
568
318k
        return nullptr;
569
318k
      }
570
571
3.19M
      if (current) { // not removed so
572
        // set previous
573
2.55M
        prev = current;
574
2.55M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
2.55M
        current = current->next;
577
2.55M
      } else {
578
642k
        if (ex_current_was_cycle_pt) {
579
345k
          cycle_pt = next;
580
345k
        }
581
642k
        current = next;
582
642k
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
3.19M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
3.19M
      return current;
598
3.51M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::forward()
Line
Count
Source
562
2.01M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
2.01M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
2.01M
      if (current) { // not removed so
572
        // set previous
573
2.01M
        prev = current;
574
2.01M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
2.01M
        current = current->next;
577
2.01M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
2.01M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
2.01M
      return current;
598
2.01M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::forward()
Line
Count
Source
562
83.0M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
83.0M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
83.0M
      if (current) { // not removed so
572
        // set previous
573
83.0M
        prev = current;
574
83.0M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
83.0M
        current = current->next;
577
83.0M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
83.0M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
83.0M
      return current;
598
83.0M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::forward()
Line
Count
Source
562
222M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
222M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
222M
      if (current) { // not removed so
572
        // set previous
573
222M
        prev = current;
574
222M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
222M
        current = current->next;
577
222M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
222M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
222M
      return current;
598
222M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::forward()
Line
Count
Source
562
422k
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
422k
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
422k
      if (current) { // not removed so
572
        // set previous
573
422k
        prev = current;
574
422k
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
422k
        current = current->next;
577
422k
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
422k
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
422k
      return current;
598
422k
    } // move to next element
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::forward()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::forward()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::forward()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::forward()
Line
Count
Source
562
736M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
736M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
736M
      if (current) { // not removed so
572
        // set previous
573
736M
        prev = current;
574
736M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
736M
        current = current->next;
577
736M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
736M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
736M
      return current;
598
736M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::forward()
Line
Count
Source
562
474k
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
474k
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
474k
      if (current) { // not removed so
572
        // set previous
573
364k
        prev = current;
574
364k
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
364k
        current = current->next;
577
364k
      } else {
578
110k
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
110k
        current = next;
582
110k
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
474k
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
474k
      return current;
598
474k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::forward()
Line
Count
Source
562
4.65M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
4.65M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
4.65M
      if (current) { // not removed so
572
        // set previous
573
4.65M
        prev = current;
574
4.65M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
4.65M
        current = current->next;
577
4.65M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
4.65M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
4.65M
      return current;
598
4.65M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::forward()
Line
Count
Source
562
1.68M
    T *forward() {
563
#ifndef NDEBUG
564
      if (!list)
565
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
566
#endif
567
1.68M
      if (list->empty()) {
568
0
        return nullptr;
569
0
      }
570
571
1.68M
      if (current) { // not removed so
572
        // set previous
573
1.68M
        prev = current;
574
1.68M
        started_cycling = true;
575
        // In case next is deleted by another iterator, get next from current.
576
1.68M
        current = current->next;
577
1.68M
      } else {
578
0
        if (ex_current_was_cycle_pt) {
579
0
          cycle_pt = next;
580
0
        }
581
0
        current = next;
582
0
      }
583
#ifndef NDEBUG
584
      if (!current)
585
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
586
#endif
587
1.68M
      next = current->next;
588
589
#ifndef NDEBUG
590
      if (!next) {
591
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
592
          "This is: %p  Current is: %p",
593
          static_cast<void *>(this),
594
          static_cast<void *>(current));
595
      }
596
#endif
597
1.68M
      return current;
598
1.68M
    } // move to next element
599
600
      /***********************************************************************
601
     *                          ELIST_ITERATOR::extract
602
     *
603
     *  Do extraction by removing current from the list, returning it to the
604
     *  caller, but NOT updating the iterator.  (So that any calling loop can do
605
     *  this.)   The iterator's current points to nullptr.  If the extracted element
606
     *  is to be deleted, this is the callers responsibility.
607
     **********************************************************************/
608
37.4M
    T *extract() {
609
37.4M
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
37.4M
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
8.43M
        prev = next = list->last = nullptr;
624
28.9M
      } else {
625
28.9M
        prev->next = next; // remove from list
626
627
28.9M
        ex_current_was_last = (current == list->last);
628
28.9M
        if (ex_current_was_last) {
629
1.09M
          list->last = prev;
630
1.09M
        }
631
28.9M
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
37.4M
      ex_current_was_cycle_pt = (current == cycle_pt);
634
37.4M
      extracted_link = current;
635
37.4M
      extracted_link->next = nullptr; // for safety
636
37.4M
      current = nullptr;
637
37.4M
      return extracted_link;
638
37.4M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::extract()
Line
Count
Source
608
4.50M
    T *extract() {
609
4.50M
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
4.50M
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
301k
        prev = next = list->last = nullptr;
624
4.20M
      } else {
625
4.20M
        prev->next = next; // remove from list
626
627
4.20M
        ex_current_was_last = (current == list->last);
628
4.20M
        if (ex_current_was_last) {
629
14.5k
          list->last = prev;
630
14.5k
        }
631
4.20M
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
4.50M
      ex_current_was_cycle_pt = (current == cycle_pt);
634
4.50M
      extracted_link = current;
635
4.50M
      extracted_link->next = nullptr; // for safety
636
4.50M
      current = nullptr;
637
4.50M
      return extracted_link;
638
4.50M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::extract()
Line
Count
Source
608
14.0M
    T *extract() {
609
14.0M
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
14.0M
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
7.40M
        prev = next = list->last = nullptr;
624
7.40M
      } else {
625
6.69M
        prev->next = next; // remove from list
626
627
6.69M
        ex_current_was_last = (current == list->last);
628
6.69M
        if (ex_current_was_last) {
629
77.3k
          list->last = prev;
630
77.3k
        }
631
6.69M
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
14.0M
      ex_current_was_cycle_pt = (current == cycle_pt);
634
14.0M
      extracted_link = current;
635
14.0M
      extracted_link->next = nullptr; // for safety
636
14.0M
      current = nullptr;
637
14.0M
      return extracted_link;
638
14.0M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::extract()
Line
Count
Source
608
129k
    T *extract() {
609
129k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
129k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
6
        prev = next = list->last = nullptr;
624
129k
      } else {
625
129k
        prev->next = next; // remove from list
626
627
129k
        ex_current_was_last = (current == list->last);
628
129k
        if (ex_current_was_last) {
629
5.47k
          list->last = prev;
630
5.47k
        }
631
129k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
129k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
129k
      extracted_link = current;
635
129k
      extracted_link->next = nullptr; // for safety
636
129k
      current = nullptr;
637
129k
      return extracted_link;
638
129k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::extract()
Line
Count
Source
608
16.0M
    T *extract() {
609
16.0M
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
16.0M
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
349k
        prev = next = list->last = nullptr;
624
15.7M
      } else {
625
15.7M
        prev->next = next; // remove from list
626
627
15.7M
        ex_current_was_last = (current == list->last);
628
15.7M
        if (ex_current_was_last) {
629
42.5k
          list->last = prev;
630
42.5k
        }
631
15.7M
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
16.0M
      ex_current_was_cycle_pt = (current == cycle_pt);
634
16.0M
      extracted_link = current;
635
16.0M
      extracted_link->next = nullptr; // for safety
636
16.0M
      current = nullptr;
637
16.0M
      return extracted_link;
638
16.0M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::extract()
Line
Count
Source
608
42.4k
    T *extract() {
609
42.4k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
42.4k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
1.43k
        prev = next = list->last = nullptr;
624
41.0k
      } else {
625
41.0k
        prev->next = next; // remove from list
626
627
41.0k
        ex_current_was_last = (current == list->last);
628
41.0k
        if (ex_current_was_last) {
629
2.99k
          list->last = prev;
630
2.99k
        }
631
41.0k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
42.4k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
42.4k
      extracted_link = current;
635
42.4k
      extracted_link->next = nullptr; // for safety
636
42.4k
      current = nullptr;
637
42.4k
      return extracted_link;
638
42.4k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::extract()
Line
Count
Source
608
475k
    T *extract() {
609
475k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
475k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
0
        prev = next = list->last = nullptr;
624
475k
      } else {
625
475k
        prev->next = next; // remove from list
626
627
475k
        ex_current_was_last = (current == list->last);
628
475k
        if (ex_current_was_last) {
629
266k
          list->last = prev;
630
266k
        }
631
475k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
475k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
475k
      extracted_link = current;
635
475k
      extracted_link->next = nullptr; // for safety
636
475k
      current = nullptr;
637
475k
      return extracted_link;
638
475k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::extract()
Line
Count
Source
608
961k
    T *extract() {
609
961k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
961k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
318k
        prev = next = list->last = nullptr;
624
642k
      } else {
625
642k
        prev->next = next; // remove from list
626
627
642k
        ex_current_was_last = (current == list->last);
628
642k
        if (ex_current_was_last) {
629
297k
          list->last = prev;
630
297k
        }
631
642k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
961k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
961k
      extracted_link = current;
635
961k
      extracted_link->next = nullptr; // for safety
636
961k
      current = nullptr;
637
961k
      return extracted_link;
638
961k
    }  // remove from list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::extract()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::extract()
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::extract()
Line
Count
Source
608
1.97k
    T *extract() {
609
1.97k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
1.97k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
1.97k
        prev = next = list->last = nullptr;
624
1.97k
      } else {
625
0
        prev->next = next; // remove from list
626
627
0
        ex_current_was_last = (current == list->last);
628
0
        if (ex_current_was_last) {
629
0
          list->last = prev;
630
0
        }
631
0
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
1.97k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
1.97k
      extracted_link = current;
635
1.97k
      extracted_link->next = nullptr; // for safety
636
1.97k
      current = nullptr;
637
1.97k
      return extracted_link;
638
1.97k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::extract()
Line
Count
Source
608
221k
    T *extract() {
609
221k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
221k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
60.5k
        prev = next = list->last = nullptr;
624
160k
      } else {
625
160k
        prev->next = next; // remove from list
626
627
160k
        ex_current_was_last = (current == list->last);
628
160k
        if (ex_current_was_last) {
629
0
          list->last = prev;
630
0
        }
631
160k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
221k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
221k
      extracted_link = current;
635
221k
      extracted_link->next = nullptr; // for safety
636
221k
      current = nullptr;
637
221k
      return extracted_link;
638
221k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::extract()
Line
Count
Source
608
911k
    T *extract() {
609
911k
      T *extracted_link;
610
611
#ifndef NDEBUG
612
      if (!list) {
613
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
614
      }
615
      if (!current) { // list empty or
616
        // element extracted
617
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
618
      }
619
#endif
620
621
911k
      if (list->singleton()) {
622
        // Special case where we do need to change the iterator.
623
0
        prev = next = list->last = nullptr;
624
911k
      } else {
625
911k
        prev->next = next; // remove from list
626
627
911k
        ex_current_was_last = (current == list->last);
628
911k
        if (ex_current_was_last) {
629
388k
          list->last = prev;
630
388k
        }
631
911k
      }
632
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
633
911k
      ex_current_was_cycle_pt = (current == cycle_pt);
634
911k
      extracted_link = current;
635
911k
      extracted_link->next = nullptr; // for safety
636
911k
      current = nullptr;
637
911k
      return extracted_link;
638
911k
    }  // remove from list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::extract()
639
      /***********************************************************************
640
     *                          ELIST_ITERATOR::move_to_first()
641
     *
642
     *  Move current so that it is set to the start of the list.
643
     *  Return data just in case anyone wants it.
644
     **********************************************************************/
645
3.56M
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
3.56M
      current = list->First();
653
3.56M
      prev = list->last;
654
3.56M
      next = current ? current->next : nullptr;
655
3.56M
      return current;
656
3.56M
    } // go to start of list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::move_to_first()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::move_to_first()
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::move_to_first()
Line
Count
Source
645
400k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
400k
      current = list->First();
653
400k
      prev = list->last;
654
400k
      next = current ? current->next : nullptr;
655
400k
      return current;
656
400k
    } // go to start of list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::move_to_first()
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::move_to_first()
Line
Count
Source
645
400k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
400k
      current = list->First();
653
400k
      prev = list->last;
654
400k
      next = current ? current->next : nullptr;
655
400k
      return current;
656
400k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::move_to_first()
Line
Count
Source
645
13.0k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
13.0k
      current = list->First();
653
13.0k
      prev = list->last;
654
13.0k
      next = current ? current->next : nullptr;
655
13.0k
      return current;
656
13.0k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::move_to_first()
Line
Count
Source
645
350k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
350k
      current = list->First();
653
350k
      prev = list->last;
654
350k
      next = current ? current->next : nullptr;
655
350k
      return current;
656
350k
    } // go to start of list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::move_to_first()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::move_to_first()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::move_to_first()
Line
Count
Source
645
118k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
118k
      current = list->First();
653
118k
      prev = list->last;
654
118k
      next = current ? current->next : nullptr;
655
118k
      return current;
656
118k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::move_to_first()
Line
Count
Source
645
110k
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
110k
      current = list->First();
653
110k
      prev = list->last;
654
110k
      next = current ? current->next : nullptr;
655
110k
      return current;
656
110k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::move_to_first()
Line
Count
Source
645
2.16M
    T *move_to_first() {
646
#ifndef NDEBUG
647
      if (!list) {
648
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
649
      }
650
#endif
651
652
2.16M
      current = list->First();
653
2.16M
      prev = list->last;
654
2.16M
      next = current ? current->next : nullptr;
655
2.16M
      return current;
656
2.16M
    } // go to start of list
657
      /***********************************************************************
658
     *              ELIST_ITERATOR::move_to_last()
659
     *
660
     *  Move current so that it is set to the end of the list.
661
     *  Return data just in case anyone wants it.
662
     *  (This function can't be INLINEd because it contains a loop)
663
     **********************************************************************/
664
6.34M
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
226M
      while (current != list->last) {
671
219M
        forward();
672
219M
      }
673
674
6.34M
      return current;
675
6.34M
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::move_to_last()
Line
Count
Source
664
21.4k
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
52.1k
      while (current != list->last) {
671
30.7k
        forward();
672
30.7k
      }
673
674
21.4k
      return current;
675
21.4k
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::move_to_last()
Line
Count
Source
664
51.9k
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
429k
      while (current != list->last) {
671
377k
        forward();
672
377k
      }
673
674
51.9k
      return current;
675
51.9k
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::move_to_last()
Line
Count
Source
664
73.7k
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
182k
      while (current != list->last) {
671
108k
        forward();
672
108k
      }
673
674
73.7k
      return current;
675
73.7k
    } // go to end of list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::move_to_last()
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::move_to_last()
Line
Count
Source
664
1.31M
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
33.3M
      while (current != list->last) {
671
32.0M
        forward();
672
32.0M
      }
673
674
1.31M
      return current;
675
1.31M
    } // go to end of list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::move_to_last()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::move_to_last()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::move_to_last()
Line
Count
Source
664
4.81M
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
191M
      while (current != list->last) {
671
186M
        forward();
672
186M
      }
673
674
4.81M
      return current;
675
4.81M
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::move_to_last()
Line
Count
Source
664
69.3k
    T *move_to_last() {
665
#ifndef NDEBUG
666
      if (!list)
667
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
668
#endif
669
670
879k
      while (current != list->last) {
671
810k
        forward();
672
810k
      }
673
674
69.3k
      return current;
675
69.3k
    } // go to end of list
676
      /***********************************************************************
677
     *                          ELIST_ITERATOR::mark_cycle_pt()
678
     *
679
     *  Remember the current location so that we can tell whether we've returned
680
     *  to this point later.
681
     *
682
     *  If the current point is deleted either now, or in the future, the cycle
683
     *  point will be set to the next item which is set to current.  This could be
684
     *  by a forward, add_after_then_move or add_after_then_move.
685
     **********************************************************************/
686
437M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
437M
      if (current) {
694
418M
        cycle_pt = current;
695
418M
      } else {
696
18.4M
        ex_current_was_cycle_pt = true;
697
18.4M
      }
698
437M
      started_cycling = false;
699
437M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::mark_cycle_pt()
Line
Count
Source
686
115k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
115k
      if (current) {
694
109k
        cycle_pt = current;
695
109k
      } else {
696
5.91k
        ex_current_was_cycle_pt = true;
697
5.91k
      }
698
115k
      started_cycling = false;
699
115k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::mark_cycle_pt()
Line
Count
Source
686
181M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
181M
      if (current) {
694
167M
        cycle_pt = current;
695
167M
      } else {
696
14.1M
        ex_current_was_cycle_pt = true;
697
14.1M
      }
698
181M
      started_cycling = false;
699
181M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::mark_cycle_pt()
Line
Count
Source
686
4.38M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
4.38M
      if (current) {
694
4.23M
        cycle_pt = current;
695
4.23M
      } else {
696
145k
        ex_current_was_cycle_pt = true;
697
145k
      }
698
4.38M
      started_cycling = false;
699
4.38M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::mark_cycle_pt()
Line
Count
Source
686
68.3k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
68.3k
      if (current) {
694
67.8k
        cycle_pt = current;
695
67.8k
      } else {
696
531
        ex_current_was_cycle_pt = true;
697
531
      }
698
68.3k
      started_cycling = false;
699
68.3k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::mark_cycle_pt()
Line
Count
Source
686
12.1M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
12.1M
      if (current) {
694
8.12M
        cycle_pt = current;
695
8.12M
      } else {
696
3.98M
        ex_current_was_cycle_pt = true;
697
3.98M
      }
698
12.1M
      started_cycling = false;
699
12.1M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::mark_cycle_pt()
Line
Count
Source
686
26.7M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
26.7M
      if (current) {
694
26.7M
        cycle_pt = current;
695
26.7M
      } else {
696
71.7k
        ex_current_was_cycle_pt = true;
697
71.7k
      }
698
26.7M
      started_cycling = false;
699
26.7M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::mark_cycle_pt()
Line
Count
Source
686
6.56M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
6.56M
      if (current) {
694
6.56M
        cycle_pt = current;
695
6.56M
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
6.56M
      started_cycling = false;
699
6.56M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::mark_cycle_pt()
Line
Count
Source
686
1.90M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
1.90M
      if (current) {
694
1.88M
        cycle_pt = current;
695
1.88M
      } else {
696
20.6k
        ex_current_was_cycle_pt = true;
697
20.6k
      }
698
1.90M
      started_cycling = false;
699
1.90M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::mark_cycle_pt()
Line
Count
Source
686
1.57M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
1.57M
      if (current) {
694
1.57M
        cycle_pt = current;
695
1.57M
      } else {
696
9.60k
        ex_current_was_cycle_pt = true;
697
9.60k
      }
698
1.57M
      started_cycling = false;
699
1.57M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
686
7.31M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
7.31M
      if (current) {
694
7.30M
        cycle_pt = current;
695
7.30M
      } else {
696
3.94k
        ex_current_was_cycle_pt = true;
697
3.94k
      }
698
7.31M
      started_cycling = false;
699
7.31M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
686
7.61M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
7.61M
      if (current) {
694
7.61M
        cycle_pt = current;
695
7.61M
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
7.61M
      started_cycling = false;
699
7.61M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
686
85.8M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
85.8M
      if (current) {
694
85.8M
        cycle_pt = current;
695
85.8M
      } else {
696
738
        ex_current_was_cycle_pt = true;
697
738
      }
698
85.8M
      started_cycling = false;
699
85.8M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::mark_cycle_pt()
Line
Count
Source
686
422k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
422k
      if (current) {
694
422k
        cycle_pt = current;
695
422k
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
422k
      started_cycling = false;
699
422k
    } // remember current
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::mark_cycle_pt()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::mark_cycle_pt()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::mark_cycle_pt()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::mark_cycle_pt()
Line
Count
Source
686
99.6M
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
99.6M
      if (current) {
694
99.6M
        cycle_pt = current;
695
99.6M
      } else {
696
6
        ex_current_was_cycle_pt = true;
697
6
      }
698
99.6M
      started_cycling = false;
699
99.6M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::mark_cycle_pt()
Line
Count
Source
686
160k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
160k
      if (current) {
694
160k
        cycle_pt = current;
695
160k
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
160k
      started_cycling = false;
699
160k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::mark_cycle_pt()
Line
Count
Source
686
911k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
911k
      if (current) {
694
911k
        cycle_pt = current;
695
911k
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
911k
      started_cycling = false;
699
911k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::mark_cycle_pt()
Line
Count
Source
686
69.3k
    void mark_cycle_pt() {
687
#ifndef NDEBUG
688
      if (!list) {
689
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
690
      }
691
#endif
692
693
69.3k
      if (current) {
694
69.3k
        cycle_pt = current;
695
69.3k
      } else {
696
0
        ex_current_was_cycle_pt = true;
697
0
      }
698
69.3k
      started_cycling = false;
699
69.3k
    } // remember current
700
701
39.2M
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
39.2M
      return list->empty();
708
39.2M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::empty() const
Line
Count
Source
701
26.2M
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
26.2M
      return list->empty();
708
26.2M
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::empty() const
Line
Count
Source
701
1.92M
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
1.92M
      return list->empty();
708
1.92M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::empty() const
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::empty() const
Line
Count
Source
701
2.34M
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
2.34M
      return list->empty();
708
2.34M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::empty() const
Line
Count
Source
701
973k
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
973k
      return list->empty();
708
973k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::empty() const
Line
Count
Source
701
7.30M
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
7.30M
      return list->empty();
708
7.30M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::empty() const
Line
Count
Source
701
326k
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
326k
      return list->empty();
708
326k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::empty() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::empty() const
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::empty() const
Line
Count
Source
701
171k
    bool empty() const { // is list empty?
702
#ifndef NDEBUG
703
      if (!list) {
704
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
705
      }
706
#endif
707
171k
      return list->empty();
708
171k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::empty() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::empty() const
709
710
    bool current_extracted() const { // current extracted?
711
      return !current;
712
    }
713
    /***********************************************************************
714
   *                          ELIST_ITERATOR::at_first()
715
   *
716
   *  Are we at the start of the list?
717
   *
718
   **********************************************************************/
719
96.1M
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
96.1M
      return ((list->empty()) || (current == list->First()) ||
728
96.1M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
74.2M
          !ex_current_was_last));                         // first and last
730
96.1M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::at_first() const
Line
Count
Source
719
790k
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
790k
      return ((list->empty()) || (current == list->First()) ||
728
790k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
618k
          !ex_current_was_last));                         // first and last
730
790k
    } // Current is first?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::at_first() const
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::at_first() const
Line
Count
Source
719
568k
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
568k
      return ((list->empty()) || (current == list->First()) ||
728
568k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
438k
          !ex_current_was_last));                         // first and last
730
568k
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::at_first() const
Line
Count
Source
719
4.71M
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
4.71M
      return ((list->empty()) || (current == list->First()) ||
728
4.71M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
3.94M
          !ex_current_was_last));                         // first and last
730
4.71M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::at_first() const
Line
Count
Source
719
35.8M
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
35.8M
      return ((list->empty()) || (current == list->First()) ||
728
35.8M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
30.0M
          !ex_current_was_last));                         // first and last
730
35.8M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::at_first() const
Line
Count
Source
719
21.2M
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
21.2M
      return ((list->empty()) || (current == list->First()) ||
728
21.2M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
12.7M
          !ex_current_was_last));                         // first and last
730
21.2M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::at_first() const
Line
Count
Source
719
812k
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
812k
      return ((list->empty()) || (current == list->First()) ||
728
812k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
721k
          !ex_current_was_last));                         // first and last
730
812k
    } // Current is first?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::at_first() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::at_first() const
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::at_first() const
Line
Count
Source
719
143k
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
143k
      return ((list->empty()) || (current == list->First()) ||
728
143k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
143k
          !ex_current_was_last));                         // first and last
730
143k
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::at_first() const
Line
Count
Source
719
31.8M
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
31.8M
      return ((list->empty()) || (current == list->First()) ||
728
31.8M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
25.5M
          !ex_current_was_last));                         // first and last
730
31.8M
    } // Current is first?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::at_first() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::at_first() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::at_first() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::at_first() const
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::at_first() const
Line
Count
Source
719
33.0k
    bool at_first() const {
720
#ifndef NDEBUG
721
      if (!list) {
722
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
723
      }
724
#endif
725
726
      // we're at a deleted
727
33.0k
      return ((list->empty()) || (current == list->First()) ||
728
33.0k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
729
0
          !ex_current_was_last));                         // first and last
730
33.0k
    } // Current is first?
731
      /***********************************************************************
732
     *                          ELIST_ITERATOR::at_last()
733
     *
734
     *  Are we at the end of the list?
735
     *
736
     **********************************************************************/
737
52.5M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
52.5M
      return ((list->empty()) || (current == list->last) ||
746
52.5M
        ((current == nullptr) && (prev == list->last) && // last point between
747
30.4M
          ex_current_was_last));                          // first and last
748
52.5M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::at_last() const
Line
Count
Source
737
639k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
639k
      return ((list->empty()) || (current == list->last) ||
746
639k
        ((current == nullptr) && (prev == list->last) && // last point between
747
504k
          ex_current_was_last));                          // first and last
748
639k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::at_last() const
Line
Count
Source
737
19.1k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
19.1k
      return ((list->empty()) || (current == list->last) ||
746
19.1k
        ((current == nullptr) && (prev == list->last) && // last point between
747
0
          ex_current_was_last));                          // first and last
748
19.1k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::at_last() const
Line
Count
Source
737
369k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
369k
      return ((list->empty()) || (current == list->last) ||
746
369k
        ((current == nullptr) && (prev == list->last) && // last point between
747
209k
          ex_current_was_last));                          // first and last
748
369k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::at_last() const
Line
Count
Source
737
15.9M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
15.9M
      return ((list->empty()) || (current == list->last) ||
746
15.9M
        ((current == nullptr) && (prev == list->last) && // last point between
747
14.4M
          ex_current_was_last));                          // first and last
748
15.9M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::at_last() const
Line
Count
Source
737
10.4M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
10.4M
      return ((list->empty()) || (current == list->last) ||
746
10.4M
        ((current == nullptr) && (prev == list->last) && // last point between
747
2.33M
          ex_current_was_last));                          // first and last
748
10.4M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::at_last() const
Line
Count
Source
737
1.40M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
1.40M
      return ((list->empty()) || (current == list->last) ||
746
1.40M
        ((current == nullptr) && (prev == list->last) && // last point between
747
753k
          ex_current_was_last));                          // first and last
748
1.40M
    } // Current is last?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::at_last() const
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::at_last() const
Line
Count
Source
737
17.2k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
17.2k
      return ((list->empty()) || (current == list->last) ||
746
17.2k
        ((current == nullptr) && (prev == list->last) && // last point between
747
0
          ex_current_was_last));                          // first and last
748
17.2k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::at_last() const
Line
Count
Source
737
160k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
160k
      return ((list->empty()) || (current == list->last) ||
746
160k
        ((current == nullptr) && (prev == list->last) && // last point between
747
143k
          ex_current_was_last));                          // first and last
748
160k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::at_last() const
Line
Count
Source
737
372k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
372k
      return ((list->empty()) || (current == list->last) ||
746
372k
        ((current == nullptr) && (prev == list->last) && // last point between
747
26.5k
          ex_current_was_last));                          // first and last
748
372k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::at_last() const
Line
Count
Source
737
19.0M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
19.0M
      return ((list->empty()) || (current == list->last) ||
746
19.0M
        ((current == nullptr) && (prev == list->last) && // last point between
747
8.46M
          ex_current_was_last));                          // first and last
748
19.0M
    } // Current is last?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::at_last() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::at_last() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::at_last() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::at_last() const
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::at_last() const
Line
Count
Source
737
130k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
130k
      return ((list->empty()) || (current == list->last) ||
746
130k
        ((current == nullptr) && (prev == list->last) && // last point between
747
33.0k
          ex_current_was_last));                          // first and last
748
130k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::at_last() const
Line
Count
Source
737
3.17M
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
3.17M
      return ((list->empty()) || (current == list->last) ||
746
3.17M
        ((current == nullptr) && (prev == list->last) && // last point between
747
2.70M
          ex_current_was_last));                          // first and last
748
3.17M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::at_last() const
Line
Count
Source
737
879k
    bool at_last() const {
738
#ifndef NDEBUG
739
      if (!list) {
740
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
741
      }
742
#endif
743
744
      // we're at a deleted
745
879k
      return ((list->empty()) || (current == list->last) ||
746
879k
        ((current == nullptr) && (prev == list->last) && // last point between
747
810k
          ex_current_was_last));                          // first and last
748
879k
    } // Current is last?
749
      /***********************************************************************
750
     *                          ELIST_ITERATOR::cycled_list()
751
     *
752
     *  Have we returned to the cycle_pt since it was set?
753
     *
754
     **********************************************************************/
755
3.12G
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
3.12G
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
3.12G
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::cycled_list() const
Line
Count
Source
755
224k
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
224k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
224k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::cycled_list() const
Line
Count
Source
755
436M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
436M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
436M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::cycled_list() const
Line
Count
Source
755
4.69M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
4.69M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
4.69M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::cycled_list() const
Line
Count
Source
755
62.9M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
62.9M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
62.9M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::cycled_list() const
Line
Count
Source
755
749k
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
749k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
749k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::cycled_list() const
Line
Count
Source
755
137M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
137M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
137M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::cycled_list() const
Line
Count
Source
755
115M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
115M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
115M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::cycled_list() const
Line
Count
Source
755
651M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
651M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
651M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::cycled_list() const
Line
Count
Source
755
11.8M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
11.8M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
11.8M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::cycled_list() const
Line
Count
Source
755
126M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
126M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
126M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::cycled_list() const
Line
Count
Source
755
205M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
205M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
205M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::cycled_list() const
Line
Count
Source
755
503M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
503M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
503M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::cycled_list() const
Line
Count
Source
755
844k
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
844k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
844k
    } // Completed a cycle?
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::Iterator::cycled_list() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::Iterator::cycled_list() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::cycled_list() const
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::cycled_list() const
Line
Count
Source
755
858M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
858M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
858M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::cycled_list() const
Line
Count
Source
755
525k
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
525k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
525k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::cycled_list() const
Line
Count
Source
755
3.64M
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
3.64M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
3.64M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::cycled_list() const
Line
Count
Source
755
948k
    bool cycled_list() const {
756
#ifndef NDEBUG
757
      if (!list) {
758
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
759
      }
760
#endif
761
762
948k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
763
948k
    } // Completed a cycle?
764
      /***********************************************************************
765
     *                          ELIST_ITERATOR::add_to_end
766
     *
767
     *  Add a new element to the end of the list without moving the iterator.
768
     *  This is provided because a single linked list cannot move to the last as
769
     *  the iterator couldn't set its prev pointer.  Adding to the end is
770
     *  essential for implementing
771
                  queues.
772
    **********************************************************************/
773
    void add_to_end(           // add at end &
774
45.5M
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
45.5M
      if (this->at_last()) {
788
21.3M
        this->add_after_stay_put(new_element);
789
24.1M
      } else {
790
24.1M
        if (this->at_first()) {
791
24.1M
          this->add_before_stay_put(new_element);
792
24.1M
          list->last = new_element;
793
24.1M
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
24.1M
      }
799
45.5M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_to_end(tesseract::C_BLOB*)
Line
Count
Source
774
639k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
639k
      if (this->at_last()) {
788
135k
        this->add_after_stay_put(new_element);
789
504k
      } else {
790
504k
        if (this->at_first()) {
791
504k
          this->add_before_stay_put(new_element);
792
504k
          list->last = new_element;
793
504k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
504k
      }
799
639k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_to_end(tesseract::BLOCK*)
Line
Count
Source
774
19.1k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
19.1k
      if (this->at_last()) {
788
19.1k
        this->add_after_stay_put(new_element);
789
19.1k
      } else {
790
0
        if (this->at_first()) {
791
0
          this->add_before_stay_put(new_element);
792
0
          list->last = new_element;
793
0
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
0
      }
799
19.1k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_to_end(tesseract::WERD_RES*)
Line
Count
Source
774
369k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
369k
      if (this->at_last()) {
788
160k
        this->add_after_stay_put(new_element);
789
209k
      } else {
790
209k
        if (this->at_first()) {
791
209k
          this->add_before_stay_put(new_element);
792
209k
          list->last = new_element;
793
209k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
209k
      }
799
369k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_to_end(tesseract::BLOBNBOX*)
Line
Count
Source
774
12.9M
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
12.9M
      if (this->at_last()) {
788
1.20M
        this->add_after_stay_put(new_element);
789
11.7M
      } else {
790
11.7M
        if (this->at_first()) {
791
11.7M
          this->add_before_stay_put(new_element);
792
11.7M
          list->last = new_element;
793
11.7M
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
11.7M
      }
799
12.9M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_to_end(tesseract::C_OUTLINE*)
Line
Count
Source
774
10.4M
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
10.4M
      if (this->at_last()) {
788
8.07M
        this->add_after_stay_put(new_element);
789
8.07M
      } else {
790
2.33M
        if (this->at_first()) {
791
2.33M
          this->add_before_stay_put(new_element);
792
2.33M
          list->last = new_element;
793
2.33M
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
2.33M
      }
799
10.4M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_to_end(tesseract::ICOORDELT*)
Line
Count
Source
774
1.40M
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
1.40M
      if (this->at_last()) {
788
647k
        this->add_after_stay_put(new_element);
789
753k
      } else {
790
753k
        if (this->at_first()) {
791
753k
          this->add_before_stay_put(new_element);
792
753k
          list->last = new_element;
793
753k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
753k
      }
799
1.40M
    } // don't move
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::add_to_end(tesseract::ROW*)
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::add_to_end(tesseract::BLOCK_RES*)
Line
Count
Source
774
17.2k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
17.2k
      if (this->at_last()) {
788
17.2k
        this->add_after_stay_put(new_element);
789
17.2k
      } else {
790
0
        if (this->at_first()) {
791
0
          this->add_before_stay_put(new_element);
792
0
          list->last = new_element;
793
0
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
0
      }
799
17.2k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::add_to_end(tesseract::ROW_RES*)
Line
Count
Source
774
160k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
160k
      if (this->at_last()) {
788
17.2k
        this->add_after_stay_put(new_element);
789
143k
      } else {
790
143k
        if (this->at_first()) {
791
143k
          this->add_before_stay_put(new_element);
792
143k
          list->last = new_element;
793
143k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
143k
      }
799
160k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_to_end(tesseract::WERD_CHOICE*)
Line
Count
Source
774
372k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
372k
      if (this->at_last()) {
788
346k
        this->add_after_stay_put(new_element);
789
346k
      } else {
790
26.5k
        if (this->at_first()) {
791
26.5k
          this->add_before_stay_put(new_element);
792
26.5k
          list->last = new_element;
793
26.5k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
26.5k
      }
799
372k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_to_end(tesseract::BLOB_CHOICE*)
Line
Count
Source
774
19.0M
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
19.0M
      if (this->at_last()) {
788
10.6M
        this->add_after_stay_put(new_element);
789
10.6M
      } else {
790
8.46M
        if (this->at_first()) {
791
8.46M
          this->add_before_stay_put(new_element);
792
8.46M
          list->last = new_element;
793
8.46M
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
8.46M
      }
799
19.0M
    } // don't move
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::add_to_end(tesseract::TO_BLOCK*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::Iterator::add_to_end(tesseract::TabConstraint*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::add_to_end(tesseract::ViterbiStateEntry*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::add_to_end(tesseract::AmbigSpec*)
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::add_to_end(tesseract::C_OUTLINE_FRAG*)
Line
Count
Source
774
130k
      T *new_element) {
775
#ifndef NDEBUG
776
      if (!list) {
777
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
778
      }
779
      if (!new_element) {
780
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
781
      }
782
      if (new_element->next) {
783
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
784
      }
785
#endif
786
787
130k
      if (this->at_last()) {
788
97.7k
        this->add_after_stay_put(new_element);
789
97.7k
      } else {
790
33.0k
        if (this->at_first()) {
791
33.0k
          this->add_before_stay_put(new_element);
792
33.0k
          list->last = new_element;
793
33.0k
        } else { // Iteratr is elsewhere
794
0
          new_element->next = list->last->next;
795
0
          list->last->next = new_element;
796
0
          list->last = new_element;
797
0
        }
798
33.0k
      }
799
130k
    } // don't move
800
        /***********************************************************************
801
     *              ELIST_ITERATOR::exchange()
802
     *
803
     *  Given another iterator, whose current element is a different element on
804
     *  the same list list OR an element of another list, exchange the two current
805
     *  elements.  On return, each iterator points to the element which was the
806
     *  other iterators current on entry.
807
     *  (This function hasn't been in-lined because its a bit big!)
808
     **********************************************************************/
809
    void exchange(                 // positions of 2 links
810
      Iterator *other_it) { // other iterator
811
      constexpr ERRCODE DONT_EXCHANGE_DELETED("Can't exchange deleted elements of lists");
812
813
      T *old_current;
814
815
#ifndef NDEBUG
816
      if (!list)
817
        NO_LIST.error("ELIST_ITERATOR::exchange", ABORT);
818
      if (!other_it)
819
        BAD_PARAMETER.error("ELIST_ITERATOR::exchange", ABORT, "other_it nullptr");
820
      if (!(other_it->list))
821
        NO_LIST.error("ELIST_ITERATOR::exchange", ABORT, "other_it");
822
#endif
823
824
      /* Do nothing if either list is empty or if both iterators reference the same
825
    link */
826
827
      if ((list->empty()) || (other_it->list->empty()) || (current == other_it->current)) {
828
        return;
829
      }
830
831
      /* Error if either current element is deleted */
832
833
      if (!current || !other_it->current) {
834
        DONT_EXCHANGE_DELETED.error("ELIST_ITERATOR.exchange", ABORT);
835
      }
836
837
      /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
838
    (other before this); non-doubleton adjacent elements (this before other);
839
    non-adjacent elements. */
840
841
    // adjacent links
842
      if ((next == other_it->current) || (other_it->next == current)) {
843
        // doubleton list
844
        if ((next == other_it->current) && (other_it->next == current)) {
845
          prev = next = current;
846
          other_it->prev = other_it->next = other_it->current;
847
        } else { // non-doubleton with
848
          // adjacent links
849
          // other before this
850
          if (other_it->next == current) {
851
            other_it->prev->next = current;
852
            other_it->current->next = next;
853
            current->next = other_it->current;
854
            other_it->next = other_it->current;
855
            prev = current;
856
          } else { // this before other
857
            prev->next = other_it->current;
858
            current->next = other_it->next;
859
            other_it->current->next = current;
860
            next = current;
861
            other_it->prev = other_it->current;
862
          }
863
        }
864
      } else { // no overlap
865
        prev->next = other_it->current;
866
        current->next = other_it->next;
867
        other_it->prev->next = current;
868
        other_it->current->next = next;
869
      }
870
871
      /* update end of list pointer when necessary (remember that the 2 iterators
872
      may iterate over different lists!) */
873
874
      if (list->last == current) {
875
        list->last = other_it->current;
876
      }
877
      if (other_it->list->last == other_it->current) {
878
        other_it->list->last = current;
879
      }
880
881
      if (current == cycle_pt) {
882
        cycle_pt = other_it->cycle_pt;
883
      }
884
      if (other_it->current == other_it->cycle_pt) {
885
        other_it->cycle_pt = cycle_pt;
886
      }
887
888
      /* The actual exchange - in all cases*/
889
890
      old_current = current;
891
      current = other_it->current;
892
      other_it->current = old_current;
893
    } // other iterator
894
895
      //# elements in list
896
9.37M
    int32_t length() const {
897
9.37M
      return list->length();
898
9.37M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::length() const
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::length() const
Line
Count
Source
896
9.37M
    int32_t length() const {
897
9.37M
      return list->length();
898
9.37M
    }
899
    /***********************************************************************
900
   *                          ELIST_ITERATOR::sort()
901
   *
902
   *  Sort the elements of the list, then reposition at the start.
903
   *
904
   **********************************************************************/
905
    void sort(          // sort elements
906
      int comparator( // comparison routine
907
652k
        const T *, const T *)) {
908
#ifndef NDEBUG
909
      if (!list) {
910
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
911
      }
912
#endif
913
914
652k
      list->sort(comparator);
915
652k
      move_to_first();
916
652k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::sort(int (*)(tesseract::ROW const*, tesseract::ROW const*))
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::sort(int (*)(tesseract::C_BLOB const*, tesseract::C_BLOB const*))
Line
Count
Source
907
257k
        const T *, const T *)) {
908
#ifndef NDEBUG
909
      if (!list) {
910
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
911
      }
912
#endif
913
914
257k
      list->sort(comparator);
915
257k
      move_to_first();
916
257k
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::sort(int (*)(tesseract::ICOORDELT const*, tesseract::ICOORDELT const*))
Line
Count
Source
907
297k
        const T *, const T *)) {
908
#ifndef NDEBUG
909
      if (!list) {
910
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
911
      }
912
#endif
913
914
297k
      list->sort(comparator);
915
297k
      move_to_first();
916
297k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::sort(int (*)(tesseract::BLOBNBOX const*, tesseract::BLOBNBOX const*))
Line
Count
Source
907
97.6k
        const T *, const T *)) {
908
#ifndef NDEBUG
909
      if (!list) {
910
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
911
      }
912
#endif
913
914
97.6k
      list->sort(comparator);
915
97.6k
      move_to_first();
916
97.6k
    }
917
  };
918
  using ITERATOR = Iterator; // compat
919
920
private:
921
  T *last = nullptr; // End of list
922
  //(Points to head)
923
604M
  T *First() { // return first
924
604M
    return last ? last->next : nullptr;
925
604M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::First()
Line
Count
Source
923
134k
  T *First() { // return first
924
134k
    return last ? last->next : nullptr;
925
134k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::First()
Line
Count
Source
923
237M
  T *First() { // return first
924
237M
    return last ? last->next : nullptr;
925
237M
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::First()
Line
Count
Source
923
52.5M
  T *First() { // return first
924
52.5M
    return last ? last->next : nullptr;
925
52.5M
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::First()
Line
Count
Source
923
102k
  T *First() { // return first
924
102k
    return last ? last->next : nullptr;
925
102k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::First()
Line
Count
Source
923
16.5M
  T *First() { // return first
924
16.5M
    return last ? last->next : nullptr;
925
16.5M
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::First()
Line
Count
Source
923
74.6M
  T *First() { // return first
924
74.6M
    return last ? last->next : nullptr;
925
74.6M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::First()
Line
Count
Source
923
6.56M
  T *First() { // return first
924
6.56M
    return last ? last->next : nullptr;
925
6.56M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::First()
Line
Count
Source
923
8.37M
  T *First() { // return first
924
8.37M
    return last ? last->next : nullptr;
925
8.37M
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::First()
Line
Count
Source
923
2.86M
  T *First() { // return first
924
2.86M
    return last ? last->next : nullptr;
925
2.86M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::First()
Line
Count
Source
923
433k
  T *First() { // return first
924
433k
    return last ? last->next : nullptr;
925
433k
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::First()
Line
Count
Source
923
17.2k
  T *First() { // return first
924
17.2k
    return last ? last->next : nullptr;
925
17.2k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::First()
Line
Count
Source
923
7.32M
  T *First() { // return first
924
7.32M
    return last ? last->next : nullptr;
925
7.32M
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::First()
Line
Count
Source
923
7.77M
  T *First() { // return first
924
7.77M
    return last ? last->next : nullptr;
925
7.77M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::First()
Line
Count
Source
923
86.5M
  T *First() { // return first
924
86.5M
    return last ? last->next : nullptr;
925
86.5M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::First()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::First()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::First()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::First()
Line
Count
Source
923
99.6M
  T *First() { // return first
924
99.6M
    return last ? last->next : nullptr;
925
99.6M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::First()
Line
Count
Source
923
425k
  T *First() { // return first
924
425k
    return last ? last->next : nullptr;
925
425k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::First()
Line
Count
Source
923
2.37M
  T *First() { // return first
924
2.37M
    return last ? last->next : nullptr;
925
2.37M
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::First()
Line
Count
Source
923
207k
  T *First() { // return first
924
207k
    return last ? last->next : nullptr;
925
207k
  }
926
927
public:
928
33.6M
  ~IntrusiveForwardList() {
929
33.6M
    clear();
930
33.6M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::~IntrusiveForwardList()
Line
Count
Source
928
19.1k
  ~IntrusiveForwardList() {
929
19.1k
    clear();
930
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::~IntrusiveForwardList()
Line
Count
Source
928
17.2k
  ~IntrusiveForwardList() {
929
17.2k
    clear();
930
17.2k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::~IntrusiveForwardList()
Line
Count
Source
928
160k
  ~IntrusiveForwardList() {
929
160k
    clear();
930
160k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::~IntrusiveForwardList()
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::~IntrusiveForwardList()
Line
Count
Source
928
1.78M
  ~IntrusiveForwardList() {
929
1.78M
    clear();
930
1.78M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::~IntrusiveForwardList()
Line
Count
Source
928
18.5M
  ~IntrusiveForwardList() {
929
18.5M
    clear();
930
18.5M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::~IntrusiveForwardList()
Line
Count
Source
928
19.1k
  ~IntrusiveForwardList() {
929
19.1k
    clear();
930
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::~IntrusiveForwardList()
Line
Count
Source
928
19.1k
  ~IntrusiveForwardList() {
929
19.1k
    clear();
930
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::~IntrusiveForwardList()
Line
Count
Source
928
723k
  ~IntrusiveForwardList() {
929
723k
    clear();
930
723k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::~IntrusiveForwardList()
Line
Count
Source
928
9.48M
  ~IntrusiveForwardList() {
929
9.48M
    clear();
930
9.48M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::~IntrusiveForwardList()
Line
Count
Source
928
822k
  ~IntrusiveForwardList() {
929
822k
    clear();
930
822k
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::~IntrusiveForwardList()
Line
Count
Source
928
19.1k
  ~IntrusiveForwardList() {
929
19.1k
    clear();
930
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::~IntrusiveForwardList()
Line
Count
Source
928
452k
  ~IntrusiveForwardList() {
929
452k
    clear();
930
452k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::~IntrusiveForwardList()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::~IntrusiveForwardList()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::~IntrusiveForwardList()
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::~IntrusiveForwardList()
Line
Count
Source
928
814k
  ~IntrusiveForwardList() {
929
814k
    clear();
930
814k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::~IntrusiveForwardList()
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::~IntrusiveForwardList()
Line
Count
Source
928
332k
  ~IntrusiveForwardList() {
929
332k
    clear();
930
332k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::~IntrusiveForwardList()
Line
Count
Source
928
202k
  ~IntrusiveForwardList() {
929
202k
    clear();
930
202k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::~IntrusiveForwardList()
Line
Count
Source
928
138k
  ~IntrusiveForwardList() {
929
138k
    clear();
930
138k
  }
931
932
  /* delete elements */
933
36.4M
  void clear() {
934
36.4M
    internal_clear();
935
36.4M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::clear()
Line
Count
Source
933
19.1k
  void clear() {
934
19.1k
    internal_clear();
935
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::clear()
Line
Count
Source
933
17.2k
  void clear() {
934
17.2k
    internal_clear();
935
17.2k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::clear()
Line
Count
Source
933
160k
  void clear() {
934
160k
    internal_clear();
935
160k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::clear()
Line
Count
Source
933
19.1k
  void clear() {
934
19.1k
    internal_clear();
935
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::clear()
Line
Count
Source
933
2.20M
  void clear() {
934
2.20M
    internal_clear();
935
2.20M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::clear()
Line
Count
Source
933
18.5M
  void clear() {
934
18.5M
    internal_clear();
935
18.5M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::clear()
Line
Count
Source
933
53.6k
  void clear() {
934
53.6k
    internal_clear();
935
53.6k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::clear()
Line
Count
Source
933
19.1k
  void clear() {
934
19.1k
    internal_clear();
935
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::clear()
Line
Count
Source
933
986k
  void clear() {
934
986k
    internal_clear();
935
986k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::clear()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::clear()
Line
Count
Source
933
452k
  void clear() {
934
452k
    internal_clear();
935
452k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::clear()
Line
Count
Source
933
2.86M
  void clear() {
934
2.86M
    internal_clear();
935
2.86M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::clear()
Line
Count
Source
933
814k
  void clear() {
934
814k
    internal_clear();
935
814k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::clear()
Line
Count
Source
933
9.48M
  void clear() {
934
9.48M
    internal_clear();
935
9.48M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::clear()
Line
Count
Source
933
19.1k
  void clear() {
934
19.1k
    internal_clear();
935
19.1k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::clear()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::clear()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::clear()
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::clear()
Line
Count
Source
933
332k
  void clear() {
934
332k
    internal_clear();
935
332k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::clear()
Line
Count
Source
933
202k
  void clear() {
934
202k
    internal_clear();
935
202k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::clear()
Line
Count
Source
933
207k
  void clear() {
934
207k
    internal_clear();
935
207k
  }
936
937
  /* Become a deep copy of src_list */
938
  template <typename U>
939
1.88M
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
940
1.88M
    Iterator from_it(const_cast<U *>(src_list));
941
1.88M
    Iterator to_it(this);
942
943
3.43M
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
944
1.55M
      to_it.add_after_then_move((*copier)(from_it.data()));
945
1.88M
  }
void tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::deep_copy<tesseract::C_OUTLINE_LIST>(tesseract::C_OUTLINE_LIST const*, tesseract::C_OUTLINE* (*)(tesseract::C_OUTLINE const*))
Line
Count
Source
939
1.55M
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
940
1.55M
    Iterator from_it(const_cast<U *>(src_list));
941
1.55M
    Iterator to_it(this);
942
943
2.48M
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
944
929k
      to_it.add_after_then_move((*copier)(from_it.data()));
945
1.55M
  }
Unexecuted instantiation: void tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::deep_copy<tesseract::ICOORDELT_LIST>(tesseract::ICOORDELT_LIST const*, tesseract::ICOORDELT* (*)(tesseract::ICOORDELT const*))
Unexecuted instantiation: void tesseract::IntrusiveForwardList<tesseract::WERD_RES>::deep_copy<tesseract::WERD_RES_LIST>(tesseract::WERD_RES_LIST const*, tesseract::WERD_RES* (*)(tesseract::WERD_RES const*))
Unexecuted instantiation: void tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::deep_copy<tesseract::BLOB_CHOICE_LIST>(tesseract::BLOB_CHOICE_LIST const*, tesseract::BLOB_CHOICE* (*)(tesseract::BLOB_CHOICE const*))
void tesseract::IntrusiveForwardList<tesseract::C_BLOB>::deep_copy<tesseract::C_BLOB_LIST>(tesseract::C_BLOB_LIST const*, tesseract::C_BLOB* (*)(tesseract::C_BLOB const*))
Line
Count
Source
939
333k
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
940
333k
    Iterator from_it(const_cast<U *>(src_list));
941
333k
    Iterator to_it(this);
942
943
957k
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
944
623k
      to_it.add_after_then_move((*copier)(from_it.data()));
945
333k
  }
946
947
  /***********************************************************************
948
   *              IntrusiveForwardList::internal_clear
949
   *
950
   *  Used by the destructor and the "clear" member function of derived list
951
   *  classes to destroy all the elements on the list.
952
   *  The calling function passes a "zapper" function which can be called to
953
   *  delete each element of the list, regardless of its derived type.  This
954
   *  technique permits a generic clear function to destroy elements of
955
   *  different derived types correctly, without requiring virtual functions and
956
   *  the consequential memory overhead.
957
   **********************************************************************/
958
959
   // destroy all links
960
36.4M
  void internal_clear() {
961
36.4M
    T *ptr;
962
36.4M
    T *next;
963
964
36.4M
    if (!empty()) {
965
14.8M
      ptr = last->next;     // set to first
966
14.8M
      last->next = nullptr; // break circle
967
14.8M
      last = nullptr;       // set list empty
968
53.9M
      while (ptr) {
969
39.1M
        next = ptr->next;
970
39.1M
        delete ptr;
971
39.1M
        ptr = next;
972
39.1M
      }
973
14.8M
    }
974
36.4M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::internal_clear()
Line
Count
Source
960
19.1k
  void internal_clear() {
961
19.1k
    T *ptr;
962
19.1k
    T *next;
963
964
19.1k
    if (!empty()) {
965
17.2k
      ptr = last->next;     // set to first
966
17.2k
      last->next = nullptr; // break circle
967
17.2k
      last = nullptr;       // set list empty
968
34.4k
      while (ptr) {
969
17.2k
        next = ptr->next;
970
17.2k
        delete ptr;
971
17.2k
        ptr = next;
972
17.2k
      }
973
17.2k
    }
974
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::internal_clear()
Line
Count
Source
960
17.2k
  void internal_clear() {
961
17.2k
    T *ptr;
962
17.2k
    T *next;
963
964
17.2k
    if (!empty()) {
965
17.2k
      ptr = last->next;     // set to first
966
17.2k
      last->next = nullptr; // break circle
967
17.2k
      last = nullptr;       // set list empty
968
177k
      while (ptr) {
969
160k
        next = ptr->next;
970
160k
        delete ptr;
971
160k
        ptr = next;
972
160k
      }
973
17.2k
    }
974
17.2k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::internal_clear()
Line
Count
Source
960
160k
  void internal_clear() {
961
160k
    T *ptr;
962
160k
    T *next;
963
964
160k
    if (!empty()) {
965
160k
      ptr = last->next;     // set to first
966
160k
      last->next = nullptr; // break circle
967
160k
      last = nullptr;       // set list empty
968
543k
      while (ptr) {
969
383k
        next = ptr->next;
970
383k
        delete ptr;
971
383k
        ptr = next;
972
383k
      }
973
160k
    }
974
160k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::internal_clear()
Line
Count
Source
960
19.1k
  void internal_clear() {
961
19.1k
    T *ptr;
962
19.1k
    T *next;
963
964
19.1k
    if (!empty()) {
965
17.2k
      ptr = last->next;     // set to first
966
17.2k
      last->next = nullptr; // break circle
967
17.2k
      last = nullptr;       // set list empty
968
34.4k
      while (ptr) {
969
17.2k
        next = ptr->next;
970
17.2k
        delete ptr;
971
17.2k
        ptr = next;
972
17.2k
      }
973
17.2k
    }
974
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::internal_clear()
Line
Count
Source
960
2.20M
  void internal_clear() {
961
2.20M
    T *ptr;
962
2.20M
    T *next;
963
964
2.20M
    if (!empty()) {
965
630k
      ptr = last->next;     // set to first
966
630k
      last->next = nullptr; // break circle
967
630k
      last = nullptr;       // set list empty
968
2.76M
      while (ptr) {
969
2.13M
        next = ptr->next;
970
2.13M
        delete ptr;
971
2.13M
        ptr = next;
972
2.13M
      }
973
630k
    }
974
2.20M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::internal_clear()
Line
Count
Source
960
18.5M
  void internal_clear() {
961
18.5M
    T *ptr;
962
18.5M
    T *next;
963
964
18.5M
    if (!empty()) {
965
2.65M
      ptr = last->next;     // set to first
966
2.65M
      last->next = nullptr; // break circle
967
2.65M
      last = nullptr;       // set list empty
968
6.78M
      while (ptr) {
969
4.13M
        next = ptr->next;
970
4.13M
        delete ptr;
971
4.13M
        ptr = next;
972
4.13M
      }
973
2.65M
    }
974
18.5M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::internal_clear()
Line
Count
Source
960
53.6k
  void internal_clear() {
961
53.6k
    T *ptr;
962
53.6k
    T *next;
963
964
53.6k
    if (!empty()) {
965
17.2k
      ptr = last->next;     // set to first
966
17.2k
      last->next = nullptr; // break circle
967
17.2k
      last = nullptr;       // set list empty
968
42.1k
      while (ptr) {
969
24.9k
        next = ptr->next;
970
24.9k
        delete ptr;
971
24.9k
        ptr = next;
972
24.9k
      }
973
17.2k
    }
974
53.6k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::internal_clear()
Line
Count
Source
960
19.1k
  void internal_clear() {
961
19.1k
    T *ptr;
962
19.1k
    T *next;
963
964
19.1k
    if (!empty()) {
965
17.2k
      ptr = last->next;     // set to first
966
17.2k
      last->next = nullptr; // break circle
967
17.2k
      last = nullptr;       // set list empty
968
177k
      while (ptr) {
969
160k
        next = ptr->next;
970
160k
        delete ptr;
971
160k
        ptr = next;
972
160k
      }
973
17.2k
    }
974
19.1k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::internal_clear()
Line
Count
Source
960
986k
  void internal_clear() {
961
986k
    T *ptr;
962
986k
    T *next;
963
964
986k
    if (!empty()) {
965
419k
      ptr = last->next;     // set to first
966
419k
      last->next = nullptr; // break circle
967
419k
      last = nullptr;       // set list empty
968
1.80M
      while (ptr) {
969
1.38M
        next = ptr->next;
970
1.38M
        delete ptr;
971
1.38M
        ptr = next;
972
1.38M
      }
973
419k
    }
974
986k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::internal_clear()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::internal_clear()
Line
Count
Source
960
452k
  void internal_clear() {
961
452k
    T *ptr;
962
452k
    T *next;
963
964
452k
    if (!empty()) {
965
212k
      ptr = last->next;     // set to first
966
212k
      last->next = nullptr; // break circle
967
212k
      last = nullptr;       // set list empty
968
3.38M
      while (ptr) {
969
3.17M
        next = ptr->next;
970
3.17M
        delete ptr;
971
3.17M
        ptr = next;
972
3.17M
      }
973
212k
    }
974
452k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::internal_clear()
Line
Count
Source
960
2.86M
  void internal_clear() {
961
2.86M
    T *ptr;
962
2.86M
    T *next;
963
964
2.86M
    if (!empty()) {
965
308k
      ptr = last->next;     // set to first
966
308k
      last->next = nullptr; // break circle
967
308k
      last = nullptr;       // set list empty
968
1.35M
      while (ptr) {
969
1.04M
        next = ptr->next;
970
1.04M
        delete ptr;
971
1.04M
        ptr = next;
972
1.04M
      }
973
308k
    }
974
2.86M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::internal_clear()
Line
Count
Source
960
814k
  void internal_clear() {
961
814k
    T *ptr;
962
814k
    T *next;
963
964
814k
    if (!empty()) {
965
814k
      ptr = last->next;     // set to first
966
814k
      last->next = nullptr; // break circle
967
814k
      last = nullptr;       // set list empty
968
6.70M
      while (ptr) {
969
5.89M
        next = ptr->next;
970
5.89M
        delete ptr;
971
5.89M
        ptr = next;
972
5.89M
      }
973
814k
    }
974
814k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::internal_clear()
Line
Count
Source
960
9.48M
  void internal_clear() {
961
9.48M
    T *ptr;
962
9.48M
    T *next;
963
964
9.48M
    if (!empty()) {
965
9.42M
      ptr = last->next;     // set to first
966
9.42M
      last->next = nullptr; // break circle
967
9.42M
      last = nullptr;       // set list empty
968
28.6M
      while (ptr) {
969
19.2M
        next = ptr->next;
970
19.2M
        delete ptr;
971
19.2M
        ptr = next;
972
19.2M
      }
973
9.42M
    }
974
9.48M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::internal_clear()
Line
Count
Source
960
19.1k
  void internal_clear() {
961
19.1k
    T *ptr;
962
19.1k
    T *next;
963
964
19.1k
    if (!empty()) {
965
19.1k
      ptr = last->next;     // set to first
966
19.1k
      last->next = nullptr; // break circle
967
19.1k
      last = nullptr;       // set list empty
968
38.3k
      while (ptr) {
969
19.1k
        next = ptr->next;
970
19.1k
        delete ptr;
971
19.1k
        ptr = next;
972
19.1k
      }
973
19.1k
    }
974
19.1k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::internal_clear()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::internal_clear()
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::internal_clear()
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::internal_clear()
Line
Count
Source
960
332k
  void internal_clear() {
961
332k
    T *ptr;
962
332k
    T *next;
963
964
332k
    if (!empty()) {
965
0
      ptr = last->next;     // set to first
966
0
      last->next = nullptr; // break circle
967
0
      last = nullptr;       // set list empty
968
0
      while (ptr) {
969
0
        next = ptr->next;
970
0
        delete ptr;
971
0
        ptr = next;
972
0
      }
973
0
    }
974
332k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::internal_clear()
Line
Count
Source
960
202k
  void internal_clear() {
961
202k
    T *ptr;
962
202k
    T *next;
963
964
202k
    if (!empty()) {
965
75.9k
      ptr = last->next;     // set to first
966
75.9k
      last->next = nullptr; // break circle
967
75.9k
      last = nullptr;       // set list empty
968
497k
      while (ptr) {
969
421k
        next = ptr->next;
970
421k
        delete ptr;
971
421k
        ptr = next;
972
421k
      }
973
75.9k
    }
974
202k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::internal_clear()
Line
Count
Source
960
207k
  void internal_clear() {
961
207k
    T *ptr;
962
207k
    T *next;
963
964
207k
    if (!empty()) {
965
69.3k
      ptr = last->next;     // set to first
966
69.3k
      last->next = nullptr; // break circle
967
69.3k
      last = nullptr;       // set list empty
968
948k
      while (ptr) {
969
879k
        next = ptr->next;
970
879k
        delete ptr;
971
879k
        ptr = next;
972
879k
      }
973
69.3k
    }
974
207k
  }
975
976
6.02G
  bool empty() const {
977
6.02G
    return !last;
978
6.02G
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::empty() const
Line
Count
Source
976
128M
  bool empty() const {
977
128M
    return !last;
978
128M
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::empty() const
Line
Count
Source
976
296M
  bool empty() const {
977
296M
    return !last;
978
296M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::empty() const
Line
Count
Source
976
727M
  bool empty() const {
977
727M
    return !last;
978
727M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::empty() const
Line
Count
Source
976
467k
  bool empty() const {
977
467k
    return !last;
978
467k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::empty() const
Line
Count
Source
976
279M
  bool empty() const {
977
279M
    return !last;
978
279M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::empty() const
Line
Count
Source
976
871M
  bool empty() const {
977
871M
    return !last;
978
871M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::empty() const
Line
Count
Source
976
78.5k
  bool empty() const {
977
78.5k
    return !last;
978
78.5k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::empty() const
Line
Count
Source
976
1.68M
  bool empty() const {
977
1.68M
    return !last;
978
1.68M
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::empty() const
Line
Count
Source
976
14.4M
  bool empty() const {
977
14.4M
    return !last;
978
14.4M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::empty() const
Line
Count
Source
976
1.28G
  bool empty() const {
977
1.28G
    return !last;
978
1.28G
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::empty() const
Line
Count
Source
976
433M
  bool empty() const {
977
433M
    return !last;
978
433M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::empty() const
Line
Count
Source
976
37.8M
  bool empty() const {
977
37.8M
    return !last;
978
37.8M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::empty() const
Line
Count
Source
976
1.62G
  bool empty() const {
977
1.62G
    return !last;
978
1.62G
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::empty() const
Line
Count
Source
976
291M
  bool empty() const {
977
291M
    return !last;
978
291M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::empty() const
Line
Count
Source
976
1.34M
  bool empty() const {
977
1.34M
    return !last;
978
1.34M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::empty() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::empty() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TabConstraint>::empty() const
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::empty() const
Line
Count
Source
976
2.11M
  bool empty() const {
977
2.11M
    return !last;
978
2.11M
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::empty() const
Line
Count
Source
976
15.2M
  bool empty() const {
977
15.2M
    return !last;
978
15.2M
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::empty() const
Line
Count
Source
976
4.60M
  bool empty() const {
977
4.60M
    return !last;
978
4.60M
  }
979
980
42.6M
  bool singleton() const {
981
42.6M
    return last ? (last == last->next) : false;
982
42.6M
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::singleton() const
Line
Count
Source
980
4.50M
  bool singleton() const {
981
4.50M
    return last ? (last == last->next) : false;
982
4.50M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::singleton() const
Line
Count
Source
980
956k
  bool singleton() const {
981
956k
    return last ? (last == last->next) : false;
982
956k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::singleton() const
Line
Count
Source
980
14.0M
  bool singleton() const {
981
14.0M
    return last ? (last == last->next) : false;
982
14.0M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::singleton() const
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::singleton() const
Line
Count
Source
980
129k
  bool singleton() const {
981
129k
    return last ? (last == last->next) : false;
982
129k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::singleton() const
Line
Count
Source
980
20.7M
  bool singleton() const {
981
20.7M
    return last ? (last == last->next) : false;
982
20.7M
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::singleton() const
Line
Count
Source
980
59.6k
  bool singleton() const {
981
59.6k
    return last ? (last == last->next) : false;
982
59.6k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::singleton() const
Line
Count
Source
980
972k
  bool singleton() const {
981
972k
    return last ? (last == last->next) : false;
982
972k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WorkingPartSet>::singleton() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ColSegment>::singleton() const
tesseract::IntrusiveForwardList<tesseract::BLOCK>::singleton() const
Line
Count
Source
980
1.97k
  bool singleton() const {
981
1.97k
    return last ? (last == last->next) : false;
982
1.97k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::singleton() const
Line
Count
Source
980
221k
  bool singleton() const {
981
221k
    return last ? (last == last->next) : false;
982
221k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::singleton() const
Line
Count
Source
980
911k
  bool singleton() const {
981
911k
    return last ? (last == last->next) : false;
982
911k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::singleton() const
983
984
  void shallow_copy(      // dangerous!!
985
    IntrusiveForwardList *from_list) { // beware destructors!!
986
    last = from_list->last;
987
  }
988
989
  /***********************************************************************
990
 *              IntrusiveForwardList::assign_to_sublist
991
 *
992
 *  The list is set to a sublist of another list.  "This" list must be empty
993
 *  before this function is invoked.  The two iterators passed must refer to
994
 *  the same list, different from "this" one.  The sublist removed is the
995
 *  inclusive list from start_it's current position to end_it's current
996
 *  position.  If this range passes over the end of the source list then the
997
 *  source list has its end set to the previous element of start_it.  The
998
 *  extracted sublist is unaffected by the end point of the source list, its
999
 *  end point is always the end_it position.
1000
 **********************************************************************/
1001
  void assign_to_sublist(       // to this list
1002
    Iterator *start_it, // from list start
1003
0
    Iterator *end_it) {  // from list end
1004
0
    constexpr ERRCODE LIST_NOT_EMPTY("Destination list must be empty before extracting a sublist");
1005
1006
0
    if (!empty()) {
1007
0
      LIST_NOT_EMPTY.error("IntrusiveForwardList.assign_to_sublist", ABORT);
1008
0
    }
1009
1010
0
    last = start_it->extract_sublist(end_it);
1011
0
  }  // from list end
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::assign_to_sublist(tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator*, tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator*)
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_BLOB>::assign_to_sublist(tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator*, tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator*)
1012
1013
    // # elements in list
1014
12.1M
  int32_t length() const {
1015
12.1M
    int32_t count = 0;
1016
12.1M
    if (last != nullptr) {
1017
9.97M
      count = 1;
1018
51.6M
      for (auto it = last->next; it != last; it = it->next) {
1019
41.6M
        count++;
1020
41.6M
      }
1021
9.97M
    }
1022
12.1M
    return count;
1023
12.1M
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::length() const
Line
Count
Source
1014
1.95M
  int32_t length() const {
1015
1.95M
    int32_t count = 0;
1016
1.95M
    if (last != nullptr) {
1017
1.94M
      count = 1;
1018
24.2M
      for (auto it = last->next; it != last; it = it->next) {
1019
22.3M
        count++;
1020
22.3M
      }
1021
1.94M
    }
1022
1.95M
    return count;
1023
1.95M
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::length() const
Line
Count
Source
1014
486k
  int32_t length() const {
1015
486k
    int32_t count = 0;
1016
486k
    if (last != nullptr) {
1017
362k
      count = 1;
1018
1.36M
      for (auto it = last->next; it != last; it = it->next) {
1019
1.00M
        count++;
1020
1.00M
      }
1021
362k
    }
1022
486k
    return count;
1023
486k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::length() const
Line
Count
Source
1014
297k
  int32_t length() const {
1015
297k
    int32_t count = 0;
1016
297k
    if (last != nullptr) {
1017
297k
      count = 1;
1018
594k
      for (auto it = last->next; it != last; it = it->next) {
1019
297k
        count++;
1020
297k
      }
1021
297k
    }
1022
297k
    return count;
1023
297k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::length() const
Line
Count
Source
1014
9.37M
  int32_t length() const {
1015
9.37M
    int32_t count = 0;
1016
9.37M
    if (last != nullptr) {
1017
7.35M
      count = 1;
1018
25.3M
      for (auto it = last->next; it != last; it = it->next) {
1019
17.9M
        count++;
1020
17.9M
      }
1021
7.35M
    }
1022
9.37M
    return count;
1023
9.37M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::length() const
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::length() const
Line
Count
Source
1014
21.4k
  int32_t length() const {
1015
21.4k
    int32_t count = 0;
1016
21.4k
    if (last != nullptr) {
1017
21.4k
      count = 1;
1018
52.1k
      for (auto it = last->next; it != last; it = it->next) {
1019
30.7k
        count++;
1020
30.7k
      }
1021
21.4k
    }
1022
21.4k
    return count;
1023
21.4k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::length() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::length() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::length() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::length() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::length() const
1024
1025
  /***********************************************************************
1026
 *              IntrusiveForwardList::sort
1027
 *
1028
 *  Sort elements on list
1029
 *  NB If you don't like the const declarations in the comparator, coerce yours:
1030
 *   ( int (*)(const void *, const void *)
1031
 **********************************************************************/
1032
  void sort(          // sort elements
1033
    int comparator( // comparison routine
1034
855k
      const T *, const T *)) {
1035
    // Allocate an array of pointers, one per list element.
1036
855k
    auto count = length();
1037
1038
855k
    if (count > 0) {
1039
      // ptr array to sort
1040
723k
      std::vector<T *> base;
1041
723k
      base.reserve(count);
1042
1043
723k
      Iterator it(this);
1044
1045
      // Extract all elements, putting the pointers in the array.
1046
10.1M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1047
9.46M
        base.push_back(it.extract());
1048
9.46M
      }
1049
1050
      // Sort the pointer array.
1051
723k
      std::sort(base.begin(), base.end(),
1052
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1053
62.3M
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
auto tesseract::IntrusiveForwardList<tesseract::C_BLOB>::sort(int (*)(tesseract::C_BLOB const*, tesseract::C_BLOB const*))::{lambda(auto:1&&, auto:2&&)#1}::operator()<tesseract::C_BLOB*&, tesseract::C_BLOB*>(tesseract::C_BLOB*&, tesseract::C_BLOB*&&) const
Line
Count
Source
1053
1.00M
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
Unexecuted instantiation: auto tesseract::IntrusiveForwardList<tesseract::ROW>::sort(int (*)(tesseract::ROW const*, tesseract::ROW const*))::{lambda(auto:1&&, auto:2&&)#1}::operator()<tesseract::ROW*&, tesseract::ROW*>(tesseract::ROW*&, tesseract::ROW*&&) const
auto tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::sort(int (*)(tesseract::ICOORDELT const*, tesseract::ICOORDELT const*))::{lambda(auto:1&&, auto:2&&)#1}::operator()<tesseract::ICOORDELT*&, tesseract::ICOORDELT*>(tesseract::ICOORDELT*&, tesseract::ICOORDELT*&&) const
Line
Count
Source
1053
297k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
auto tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::sort(int (*)(tesseract::BLOBNBOX const*, tesseract::BLOBNBOX const*))::{lambda(auto:1&&, auto:2&&)#1}::operator()<tesseract::BLOBNBOX*&, tesseract::BLOBNBOX*>(tesseract::BLOBNBOX*&, tesseract::BLOBNBOX*&&) const
Line
Count
Source
1053
61.0M
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1054
1055
      // Rebuild the list from the sorted pointers.
1056
9.46M
      for (auto current : base) {
1057
9.46M
        it.add_to_end(current);
1058
9.46M
      }
1059
723k
    }
1060
855k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::sort(int (*)(tesseract::C_BLOB const*, tesseract::C_BLOB const*))
Line
Count
Source
1034
257k
      const T *, const T *)) {
1035
    // Allocate an array of pointers, one per list element.
1036
257k
    auto count = length();
1037
1038
257k
    if (count > 0) {
1039
      // ptr array to sort
1040
135k
      std::vector<T *> base;
1041
135k
      base.reserve(count);
1042
1043
135k
      Iterator it(this);
1044
1045
      // Extract all elements, putting the pointers in the array.
1046
775k
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1047
639k
        base.push_back(it.extract());
1048
639k
      }
1049
1050
      // Sort the pointer array.
1051
135k
      std::sort(base.begin(), base.end(),
1052
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1053
135k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1054
1055
      // Rebuild the list from the sorted pointers.
1056
639k
      for (auto current : base) {
1057
639k
        it.add_to_end(current);
1058
639k
      }
1059
135k
    }
1060
257k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ROW>::sort(int (*)(tesseract::ROW const*, tesseract::ROW const*))
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::sort(int (*)(tesseract::ICOORDELT const*, tesseract::ICOORDELT const*))
Line
Count
Source
1034
297k
      const T *, const T *)) {
1035
    // Allocate an array of pointers, one per list element.
1036
297k
    auto count = length();
1037
1038
297k
    if (count > 0) {
1039
      // ptr array to sort
1040
297k
      std::vector<T *> base;
1041
297k
      base.reserve(count);
1042
1043
297k
      Iterator it(this);
1044
1045
      // Extract all elements, putting the pointers in the array.
1046
891k
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1047
594k
        base.push_back(it.extract());
1048
594k
      }
1049
1050
      // Sort the pointer array.
1051
297k
      std::sort(base.begin(), base.end(),
1052
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1053
297k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1054
1055
      // Rebuild the list from the sorted pointers.
1056
594k
      for (auto current : base) {
1057
594k
        it.add_to_end(current);
1058
594k
      }
1059
297k
    }
1060
297k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::sort(int (*)(tesseract::BLOBNBOX const*, tesseract::BLOBNBOX const*))
Line
Count
Source
1034
300k
      const T *, const T *)) {
1035
    // Allocate an array of pointers, one per list element.
1036
300k
    auto count = length();
1037
1038
300k
    if (count > 0) {
1039
      // ptr array to sort
1040
290k
      std::vector<T *> base;
1041
290k
      base.reserve(count);
1042
1043
290k
      Iterator it(this);
1044
1045
      // Extract all elements, putting the pointers in the array.
1046
8.52M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1047
8.23M
        base.push_back(it.extract());
1048
8.23M
      }
1049
1050
      // Sort the pointer array.
1051
290k
      std::sort(base.begin(), base.end(),
1052
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1053
290k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1054
1055
      // Rebuild the list from the sorted pointers.
1056
8.23M
      for (auto current : base) {
1057
8.23M
        it.add_to_end(current);
1058
8.23M
      }
1059
290k
    }
1060
300k
  }
1061
1062
  // Assuming list has been sorted already, insert new_link to
1063
  // keep the list sorted according to the same comparison function.
1064
  // Comparison function is the same as used by sort, i.e. uses double
1065
  // indirection. Time is O(1) to add to beginning or end.
1066
  // Time is linear to add pre-sorted items to an empty list.
1067
  // If unique is set to true and comparator() returns 0 (an entry with the
1068
  // same information as the one contained in new_link is already in the
1069
  // list) - new_link is not added to the list and the function returns the
1070
  // pointer to the identical entry that already exists in the list
1071
  // (otherwise the function returns new_link).
1072
  T *add_sorted_and_find(int comparator(const T *, const T *), bool unique,
1073
5.96M
    T *new_link) {
1074
    // Check for adding at the end.
1075
5.96M
    if (last == nullptr || comparator(last, new_link) < 0) {
1076
1.49M
      if (last == nullptr) {
1077
814k
        new_link->next = new_link;
1078
814k
      } else {
1079
675k
        new_link->next = last->next;
1080
675k
        last->next = new_link;
1081
675k
      }
1082
1.49M
      last = new_link;
1083
4.47M
    } else {
1084
      // Need to use an iterator.
1085
4.47M
      Iterator it(this);
1086
21.3M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1087
21.3M
        auto *link = it.data();
1088
21.3M
        int compare = comparator(link, new_link);
1089
21.3M
        if (compare > 0) {
1090
4.47M
          break;
1091
16.8M
        } else if (unique && compare == 0) {
1092
228
          return link;
1093
228
        }
1094
21.3M
      }
1095
4.47M
      if (it.cycled_list()) {
1096
0
        it.add_to_end(new_link);
1097
4.47M
      } else {
1098
4.47M
        it.add_before_then_move(new_link);
1099
4.47M
      }
1100
4.47M
    }
1101
5.96M
    return new_link;
1102
5.96M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::add_sorted_and_find(int (*)(tesseract::ViterbiStateEntry const*, tesseract::ViterbiStateEntry const*), bool, tesseract::ViterbiStateEntry*)
Line
Count
Source
1073
5.89M
    T *new_link) {
1074
    // Check for adding at the end.
1075
5.89M
    if (last == nullptr || comparator(last, new_link) < 0) {
1076
1.48M
      if (last == nullptr) {
1077
814k
        new_link->next = new_link;
1078
814k
      } else {
1079
674k
        new_link->next = last->next;
1080
674k
        last->next = new_link;
1081
674k
      }
1082
1.48M
      last = new_link;
1083
4.40M
    } else {
1084
      // Need to use an iterator.
1085
4.40M
      Iterator it(this);
1086
10.9M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1087
10.9M
        auto *link = it.data();
1088
10.9M
        int compare = comparator(link, new_link);
1089
10.9M
        if (compare > 0) {
1090
4.40M
          break;
1091
6.51M
        } else if (unique && compare == 0) {
1092
0
          return link;
1093
0
        }
1094
10.9M
      }
1095
4.40M
      if (it.cycled_list()) {
1096
0
        it.add_to_end(new_link);
1097
4.40M
      } else {
1098
4.40M
        it.add_before_then_move(new_link);
1099
4.40M
      }
1100
4.40M
    }
1101
5.89M
    return new_link;
1102
5.89M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::add_sorted_and_find(int (*)(tesseract::AmbigSpec const*, tesseract::AmbigSpec const*), bool, tesseract::AmbigSpec*)
Line
Count
Source
1073
76.1k
    T *new_link) {
1074
    // Check for adding at the end.
1075
76.1k
    if (last == nullptr || comparator(last, new_link) < 0) {
1076
1.54k
      if (last == nullptr) {
1077
304
        new_link->next = new_link;
1078
1.23k
      } else {
1079
1.23k
        new_link->next = last->next;
1080
1.23k
        last->next = new_link;
1081
1.23k
      }
1082
1.54k
      last = new_link;
1083
74.6k
    } else {
1084
      // Need to use an iterator.
1085
74.6k
      Iterator it(this);
1086
10.4M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1087
10.4M
        auto *link = it.data();
1088
10.4M
        int compare = comparator(link, new_link);
1089
10.4M
        if (compare > 0) {
1090
74.3k
          break;
1091
10.3M
        } else if (unique && compare == 0) {
1092
228
          return link;
1093
228
        }
1094
10.4M
      }
1095
74.3k
      if (it.cycled_list()) {
1096
0
        it.add_to_end(new_link);
1097
74.3k
      } else {
1098
74.3k
        it.add_before_then_move(new_link);
1099
74.3k
      }
1100
74.3k
    }
1101
75.9k
    return new_link;
1102
76.1k
  }
1103
1104
  // Same as above, but returns true if the new entry was inserted, false
1105
  // if the identical entry already existed in the list.
1106
5.96M
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1107
5.96M
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1108
5.96M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::add_sorted(int (*)(tesseract::ViterbiStateEntry const*, tesseract::ViterbiStateEntry const*), bool, tesseract::ViterbiStateEntry*)
Line
Count
Source
1106
5.89M
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1107
5.89M
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1108
5.89M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::add_sorted(int (*)(tesseract::AmbigSpec const*, tesseract::AmbigSpec const*), bool, tesseract::AmbigSpec*)
Line
Count
Source
1106
76.1k
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1107
76.1k
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1108
76.1k
  }
1109
};
1110
1111
template <typename CLASSNAME>
1112
using ELIST = IntrusiveForwardList<CLASSNAME>;
1113
1114
// add TESS_API?
1115
// move templated lists to public include dirs?
1116
#define ELISTIZEH(T)                                        \
1117
  class T##_LIST : public IntrusiveForwardList<T> {         \
1118
  public:                                                   \
1119
    using IntrusiveForwardList<T>::IntrusiveForwardList;    \
1120
  };                                                        \
1121
  class T##_IT : public IntrusiveForwardList<T>::Iterator { \
1122
  public:                                                   \
1123
    using IntrusiveForwardList<T>::Iterator::Iterator;      \
1124
  };
1125
1126
} // namespace tesseract
1127
1128
#endif