Coverage Report

Created: 2026-01-13 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tesseract/src/ccutil/elst.h
Line
Count
Source
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
62.8M
    Link() {
97
62.8M
      next = nullptr;
98
62.8M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link::Link()
Line
Count
Source
96
3.03M
    Link() {
97
3.03M
      next = nullptr;
98
3.03M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link::Link()
Line
Count
Source
96
687k
    Link() {
97
687k
      next = nullptr;
98
687k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Link::Link()
Line
Count
Source
96
3.83M
    Link() {
97
3.83M
      next = nullptr;
98
3.83M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Link::Link()
Line
Count
Source
96
4.34M
    Link() {
97
4.34M
      next = nullptr;
98
4.34M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Link::Link()
Line
Count
Source
96
1.65M
    Link() {
97
1.65M
      next = nullptr;
98
1.65M
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Link::Link()
Line
Count
Source
96
21.0k
    Link() {
97
21.0k
      next = nullptr;
98
21.0k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Link::Link()
Line
Count
Source
96
3.08M
    Link() {
97
3.08M
      next = nullptr;
98
3.08M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Link::Link()
Line
Count
Source
96
16.2k
    Link() {
97
16.2k
      next = nullptr;
98
16.2k
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link::Link()
Line
Count
Source
96
20.3M
    Link() {
97
20.3M
      next = nullptr;
98
20.3M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Link::Link()
Line
Count
Source
96
16.2k
    Link() {
97
16.2k
      next = nullptr;
98
16.2k
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Link::Link()
Line
Count
Source
96
178k
    Link() {
97
178k
      next = nullptr;
98
178k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Link::Link()
Line
Count
Source
96
14.4k
    Link() {
97
14.4k
      next = nullptr;
98
14.4k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Link::Link()
Line
Count
Source
96
140k
    Link() {
97
140k
      next = nullptr;
98
140k
    }
tesseract::IntrusiveForwardList<tesseract::TrainingSample>::Link::Link()
Line
Count
Source
96
1.96M
    Link() {
97
1.96M
      next = nullptr;
98
1.96M
    }
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
21.0M
    Link() {
97
21.0M
      next = nullptr;
98
21.0M
    }
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
234k
    Link() {
97
234k
      next = nullptr;
98
234k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Link::Link()
Line
Count
Source
96
1.28M
    Link() {
97
1.28M
      next = nullptr;
98
1.28M
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Link::Link()
Line
Count
Source
96
884k
    Link() {
97
884k
      next = nullptr;
98
884k
    }
99
    // constructor
100
101
    // The special copy constructor is used by lots of classes.
102
1.10M
    Link(const Link &) {
103
1.10M
      next = nullptr;
104
1.10M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link::Link(tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Link const&)
Line
Count
Source
102
31.4k
    Link(const Link &) {
103
31.4k
      next = nullptr;
104
31.4k
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link::Link(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Link const&)
Line
Count
Source
102
1.00M
    Link(const Link &) {
103
1.00M
      next = nullptr;
104
1.00M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link::Link(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Link const&)
Line
Count
Source
102
70.8k
    Link(const Link &) {
103
70.8k
      next = nullptr;
104
70.8k
    }
105
106
    // The special assignment operator is used by lots of classes.
107
31.4k
    void operator=(const Link &) {
108
31.4k
      next = nullptr;
109
31.4k
    }
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
31.4k
    void operator=(const Link &) {
108
31.4k
      next = nullptr;
109
31.4k
    }
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
82.2M
    Iterator() { // constructor
211
82.2M
      list = nullptr;
212
82.2M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::Iterator()
Line
Count
Source
210
901k
    Iterator() { // constructor
211
901k
      list = nullptr;
212
901k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::Iterator()
Line
Count
Source
210
901k
    Iterator() { // constructor
211
901k
      list = nullptr;
212
901k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::Iterator()
Line
Count
Source
210
2.70M
    Iterator() { // constructor
211
2.70M
      list = nullptr;
212
2.70M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::Iterator()
Line
Count
Source
210
7.17M
    Iterator() { // constructor
211
7.17M
      list = nullptr;
212
7.17M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::Iterator()
Line
Count
Source
210
470k
    Iterator() { // constructor
211
470k
      list = nullptr;
212
470k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::Iterator()
Line
Count
Source
210
64.8k
    Iterator() { // constructor
211
64.8k
      list = nullptr;
212
64.8k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::Iterator()
Line
Count
Source
210
6.57M
    Iterator() { // constructor
211
6.57M
      list = nullptr;
212
6.57M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::Iterator()
Line
Count
Source
210
2.53M
    Iterator() { // constructor
211
2.53M
      list = nullptr;
212
2.53M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::Iterator()
Line
Count
Source
210
3.52M
    Iterator() { // constructor
211
3.52M
      list = nullptr;
212
3.52M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::Iterator()
Line
Count
Source
210
16.2k
    Iterator() { // constructor
211
16.2k
      list = nullptr;
212
16.2k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::Iterator()
Line
Count
Source
210
57.0M
    Iterator() { // constructor
211
57.0M
      list = nullptr;
212
57.0M
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::Iterator()
Line
Count
Source
210
178k
    Iterator() { // constructor
211
178k
      list = nullptr;
212
178k
    } // unassigned list
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::Iterator()
Line
Count
Source
210
133k
    Iterator() { // constructor
211
133k
      list = nullptr;
212
133k
    } // unassigned list
213
    /***********************************************************************
214
   *                          ELIST_ITERATOR::ELIST_ITERATOR
215
   *
216
   *  CONSTRUCTOR - set iterator to specified list;
217
   **********************************************************************/
218
365M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
365M
      set_to_list(list_to_iterate);
220
365M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
Line
Count
Source
218
113k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
113k
      set_to_list(list_to_iterate);
220
113k
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ROW>*)
Line
Count
Source
218
57.4k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
57.4k
      set_to_list(list_to_iterate);
220
57.4k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
218
11.9M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
11.9M
      set_to_list(list_to_iterate);
220
11.9M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>*)
Line
Count
Source
218
40.3M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
40.3M
      set_to_list(list_to_iterate);
220
40.3M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::AmbigSpec>*)
Line
Count
Source
218
8.03M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
8.03M
      set_to_list(list_to_iterate);
220
8.03M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>*)
Line
Count
Source
218
2.98M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
2.98M
      set_to_list(list_to_iterate);
220
2.98M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
218
214M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
214M
      set_to_list(list_to_iterate);
220
214M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Line
Count
Source
218
829k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
829k
      set_to_list(list_to_iterate);
220
829k
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
Line
Count
Source
218
291k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
291k
      set_to_list(list_to_iterate);
220
291k
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::PARA>*)
Line
Count
Source
218
14.4k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
14.4k
      set_to_list(list_to_iterate);
220
14.4k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
Line
Count
Source
218
12.6M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
12.6M
      set_to_list(list_to_iterate);
220
12.6M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::WERD_RES>*)
Line
Count
Source
218
358k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
358k
      set_to_list(list_to_iterate);
220
358k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>*)
Line
Count
Source
218
16.2k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
16.2k
      set_to_list(list_to_iterate);
220
16.2k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::ROW_RES>*)
Line
Count
Source
218
281k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
281k
      set_to_list(list_to_iterate);
220
281k
    }
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
73.1M
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
73.1M
      set_to_list(list_to_iterate);
220
73.1M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>*)
Line
Count
Source
218
299k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
299k
      set_to_list(list_to_iterate);
220
299k
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::Iterator(tesseract::IntrusiveForwardList<tesseract::FPSEGPT>*)
Line
Count
Source
218
133k
    Iterator(IntrusiveForwardList *list_to_iterate) {
219
133k
      set_to_list(list_to_iterate);
220
133k
    }
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
510M
      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
510M
      list = list_to_iterate;
236
510M
      prev = list->last;
237
510M
      current = list->First();
238
510M
      next = current ? current->next : nullptr;
239
510M
      cycle_pt = nullptr; // await explicit set
240
510M
      started_cycling = false;
241
510M
      ex_current_was_last = false;
242
510M
      ex_current_was_cycle_pt = false;
243
510M
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOCK>*)
Line
Count
Source
228
113k
      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
113k
      list = list_to_iterate;
236
113k
      prev = list->last;
237
113k
      current = list->First();
238
113k
      next = current ? current->next : nullptr;
239
113k
      cycle_pt = nullptr; // await explicit set
240
113k
      started_cycling = false;
241
113k
      ex_current_was_last = false;
242
113k
      ex_current_was_cycle_pt = false;
243
113k
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
228
234M
      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
234M
      list = list_to_iterate;
236
234M
      prev = list->last;
237
234M
      current = list->First();
238
234M
      next = current ? current->next : nullptr;
239
234M
      cycle_pt = nullptr; // await explicit set
240
234M
      started_cycling = false;
241
234M
      ex_current_was_last = false;
242
234M
      ex_current_was_cycle_pt = false;
243
234M
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
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::ROW>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ROW>*)
Line
Count
Source
228
86.0k
      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
86.0k
      list = list_to_iterate;
236
86.0k
      prev = list->last;
237
86.0k
      current = list->First();
238
86.0k
      next = current ? current->next : nullptr;
239
86.0k
      cycle_pt = nullptr; // await explicit set
240
86.0k
      started_cycling = false;
241
86.0k
      ex_current_was_last = false;
242
86.0k
      ex_current_was_cycle_pt = false;
243
86.0k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
228
13.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
13.6M
      list = list_to_iterate;
236
13.6M
      prev = list->last;
237
13.6M
      current = list->First();
238
13.6M
      next = current ? current->next : nullptr;
239
13.6M
      cycle_pt = nullptr; // await explicit set
240
13.6M
      started_cycling = false;
241
13.6M
      ex_current_was_last = false;
242
13.6M
      ex_current_was_cycle_pt = false;
243
13.6M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>*)
Line
Count
Source
228
42.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
42.9M
      list = list_to_iterate;
236
42.9M
      prev = list->last;
237
42.9M
      current = list->First();
238
42.9M
      next = current ? current->next : nullptr;
239
42.9M
      cycle_pt = nullptr; // await explicit set
240
42.9M
      started_cycling = false;
241
42.9M
      ex_current_was_last = false;
242
42.9M
      ex_current_was_cycle_pt = false;
243
42.9M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::AmbigSpec>*)
Line
Count
Source
228
8.03M
      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
8.03M
      list = list_to_iterate;
236
8.03M
      prev = list->last;
237
8.03M
      current = list->First();
238
8.03M
      next = current ? current->next : nullptr;
239
8.03M
      cycle_pt = nullptr; // await explicit set
240
8.03M
      started_cycling = false;
241
8.03M
      ex_current_was_last = false;
242
8.03M
      ex_current_was_cycle_pt = false;
243
8.03M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>*)
Line
Count
Source
228
2.98M
      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
2.98M
      list = list_to_iterate;
236
2.98M
      prev = list->last;
237
2.98M
      current = list->First();
238
2.98M
      next = current ? current->next : nullptr;
239
2.98M
      cycle_pt = nullptr; // await explicit set
240
2.98M
      started_cycling = false;
241
2.98M
      ex_current_was_last = false;
242
2.98M
      ex_current_was_cycle_pt = false;
243
2.98M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ICOORDELT>*)
Line
Count
Source
228
1.49M
      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.49M
      list = list_to_iterate;
236
1.49M
      prev = list->last;
237
1.49M
      current = list->First();
238
1.49M
      next = current ? current->next : nullptr;
239
1.49M
      cycle_pt = nullptr; // await explicit set
240
1.49M
      started_cycling = false;
241
1.49M
      ex_current_was_last = false;
242
1.49M
      ex_current_was_cycle_pt = false;
243
1.49M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>*)
Line
Count
Source
228
372k
      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
372k
      list = list_to_iterate;
236
372k
      prev = list->last;
237
372k
      current = list->First();
238
372k
      next = current ? current->next : nullptr;
239
372k
      cycle_pt = nullptr; // await explicit set
240
372k
      started_cycling = false;
241
372k
      ex_current_was_last = false;
242
372k
      ex_current_was_cycle_pt = false;
243
372k
    }
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::PARA>*)
Line
Count
Source
228
14.4k
      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.4k
      list = list_to_iterate;
236
14.4k
      prev = list->last;
237
14.4k
      current = list->First();
238
14.4k
      next = current ? current->next : nullptr;
239
14.4k
      cycle_pt = nullptr; // await explicit set
240
14.4k
      started_cycling = false;
241
14.4k
      ex_current_was_last = false;
242
14.4k
      ex_current_was_cycle_pt = false;
243
14.4k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>*)
Line
Count
Source
228
6.47M
      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.47M
      list = list_to_iterate;
236
6.47M
      prev = list->last;
237
6.47M
      current = list->First();
238
6.47M
      next = current ? current->next : nullptr;
239
6.47M
      cycle_pt = nullptr; // await explicit set
240
6.47M
      started_cycling = false;
241
6.47M
      ex_current_was_last = false;
242
6.47M
      ex_current_was_cycle_pt = false;
243
6.47M
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::ROW_RES>*)
Line
Count
Source
228
6.73M
      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.73M
      list = list_to_iterate;
236
6.73M
      prev = list->last;
237
6.73M
      current = list->First();
238
6.73M
      next = current ? current->next : nullptr;
239
6.73M
      cycle_pt = nullptr; // await explicit set
240
6.73M
      started_cycling = false;
241
6.73M
      ex_current_was_last = false;
242
6.73M
      ex_current_was_cycle_pt = false;
243
6.73M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::WERD_RES>*)
Line
Count
Source
228
77.8M
      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
77.8M
      list = list_to_iterate;
236
77.8M
      prev = list->last;
237
77.8M
      current = list->First();
238
77.8M
      next = current ? current->next : nullptr;
239
77.8M
      cycle_pt = nullptr; // await explicit set
240
77.8M
      started_cycling = false;
241
77.8M
      ex_current_was_last = false;
242
77.8M
      ex_current_was_cycle_pt = false;
243
77.8M
    }
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.0M
      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.0M
      list = list_to_iterate;
236
99.0M
      prev = list->last;
237
99.0M
      current = list->First();
238
99.0M
      next = current ? current->next : nullptr;
239
99.0M
      cycle_pt = nullptr; // await explicit set
240
99.0M
      started_cycling = false;
241
99.0M
      ex_current_was_last = false;
242
99.0M
      ex_current_was_cycle_pt = false;
243
99.0M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>*)
Line
Count
Source
228
299k
      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
299k
      list = list_to_iterate;
236
299k
      prev = list->last;
237
299k
      current = list->First();
238
299k
      next = current ? current->next : nullptr;
239
299k
      cycle_pt = nullptr; // await explicit set
240
299k
      started_cycling = false;
241
299k
      ex_current_was_last = false;
242
299k
      ex_current_was_cycle_pt = false;
243
299k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>*)
Line
Count
Source
228
178k
      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
178k
      list = list_to_iterate;
236
178k
      prev = list->last;
237
178k
      current = list->First();
238
178k
      next = current ? current->next : nullptr;
239
178k
      cycle_pt = nullptr; // await explicit set
240
178k
      started_cycling = false;
241
178k
      ex_current_was_last = false;
242
178k
      ex_current_was_cycle_pt = false;
243
178k
    }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::set_to_list(tesseract::IntrusiveForwardList<tesseract::FPSEGPT>*)
Line
Count
Source
228
200k
      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
200k
      list = list_to_iterate;
236
200k
      prev = list->last;
237
200k
      current = list->First();
238
200k
      next = current ? current->next : nullptr;
239
200k
      cycle_pt = nullptr; // await explicit set
240
200k
      started_cycling = false;
241
200k
      ex_current_was_last = false;
242
200k
      ex_current_was_cycle_pt = false;
243
200k
    }
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
20.3M
      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
20.3M
      if (list->empty()) {
265
4.76M
        new_element->next = new_element;
266
4.76M
        list->last = new_element;
267
4.76M
        prev = next = new_element;
268
15.5M
      } else {
269
15.5M
        new_element->next = next;
270
271
15.5M
        if (current) { // not extracted
272
15.5M
          current->next = new_element;
273
15.5M
          prev = current;
274
15.5M
          if (current == list->last) {
275
14.7M
            list->last = new_element;
276
14.7M
          }
277
15.5M
        } else { // current extracted
278
805
          prev->next = new_element;
279
805
          if (ex_current_was_last) {
280
471
            list->last = new_element;
281
471
          }
282
805
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
805
        }
286
15.5M
      }
287
20.3M
      current = new_element;
288
20.3M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_after_then_move(tesseract::C_OUTLINE*)
Line
Count
Source
251
7.25M
      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.25M
      if (list->empty()) {
265
3.61M
        new_element->next = new_element;
266
3.61M
        list->last = new_element;
267
3.61M
        prev = next = new_element;
268
3.64M
      } else {
269
3.64M
        new_element->next = next;
270
271
3.64M
        if (current) { // not extracted
272
3.64M
          current->next = new_element;
273
3.64M
          prev = current;
274
3.64M
          if (current == list->last) {
275
3.60M
            list->last = new_element;
276
3.60M
          }
277
3.64M
        } else { // current extracted
278
805
          prev->next = new_element;
279
805
          if (ex_current_was_last) {
280
471
            list->last = new_element;
281
471
          }
282
805
          if (ex_current_was_cycle_pt) {
283
0
            cycle_pt = new_element;
284
0
          }
285
805
        }
286
3.64M
      }
287
7.25M
      current = new_element;
288
7.25M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_after_then_move(tesseract::ICOORDELT*)
Line
Count
Source
251
952k
      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
952k
      if (list->empty()) {
265
87.5k
        new_element->next = new_element;
266
87.5k
        list->last = new_element;
267
87.5k
        prev = next = new_element;
268
865k
      } else {
269
865k
        new_element->next = next;
270
271
865k
        if (current) { // not extracted
272
865k
          current->next = new_element;
273
865k
          prev = current;
274
865k
          if (current == list->last) {
275
865k
            list->last = new_element;
276
865k
          }
277
865k
        } 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
865k
      }
287
952k
      current = new_element;
288
952k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::PARA>::Iterator::add_after_then_move(tesseract::PARA*)
Line
Count
Source
251
21.0k
      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.0k
      if (list->empty()) {
265
14.4k
        new_element->next = new_element;
266
14.4k
        list->last = new_element;
267
14.4k
        prev = next = new_element;
268
14.4k
      } else {
269
6.60k
        new_element->next = next;
270
271
6.60k
        if (current) { // not extracted
272
6.60k
          current->next = new_element;
273
6.60k
          prev = current;
274
6.60k
          if (current == list->last) {
275
6.60k
            list->last = new_element;
276
6.60k
          }
277
6.60k
        } 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
6.60k
      }
287
21.0k
      current = new_element;
288
21.0k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_after_then_move(tesseract::C_BLOB*)
Line
Count
Source
251
5.58M
      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.58M
      if (list->empty()) {
265
758k
        new_element->next = new_element;
266
758k
        list->last = new_element;
267
758k
        prev = next = new_element;
268
4.83M
      } else {
269
4.83M
        new_element->next = next;
270
271
4.83M
        if (current) { // not extracted
272
4.83M
          current->next = new_element;
273
4.83M
          prev = current;
274
4.83M
          if (current == list->last) {
275
4.79M
            list->last = new_element;
276
4.79M
          }
277
4.83M
        } 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
4.83M
      }
287
5.58M
      current = new_element;
288
5.58M
    } // 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
503k
      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
503k
      if (list->empty()) {
265
29.1k
        new_element->next = new_element;
266
29.1k
        list->last = new_element;
267
29.1k
        prev = next = new_element;
268
474k
      } else {
269
474k
        new_element->next = next;
270
271
474k
        if (current) { // not extracted
272
474k
          current->next = new_element;
273
474k
          prev = current;
274
474k
          if (current == list->last) {
275
474k
            list->last = new_element;
276
474k
          }
277
474k
        } 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
474k
      }
287
503k
      current = new_element;
288
503k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_after_then_move(tesseract::BLOBNBOX*)
Line
Count
Source
251
5.61M
      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.61M
      if (list->empty()) {
265
52.2k
        new_element->next = new_element;
266
52.2k
        list->last = new_element;
267
52.2k
        prev = next = new_element;
268
5.56M
      } else {
269
5.56M
        new_element->next = next;
270
271
5.56M
        if (current) { // not extracted
272
5.56M
          current->next = new_element;
273
5.56M
          prev = current;
274
5.56M
          if (current == list->last) {
275
4.79M
            list->last = new_element;
276
4.79M
          }
277
5.56M
        } 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.56M
      }
287
5.61M
      current = new_element;
288
5.61M
    } // move to new
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_after_then_move(tesseract::BLOB_CHOICE*)
Line
Count
Source
251
174k
      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
174k
      if (list->empty()) {
265
174k
        new_element->next = new_element;
266
174k
        list->last = new_element;
267
174k
        prev = next = new_element;
268
174k
      } 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
174k
      current = new_element;
288
174k
    } // 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
16.2k
      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
16.2k
      if (list->empty()) {
265
16.2k
        new_element->next = new_element;
266
16.2k
        list->last = new_element;
267
16.2k
        prev = next = new_element;
268
16.2k
      } 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
16.2k
      current = new_element;
288
16.2k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::add_after_then_move(tesseract::ROW*)
Line
Count
Source
251
178k
      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
178k
      if (list->empty()) {
265
15.7k
        new_element->next = new_element;
266
15.7k
        list->last = new_element;
267
15.7k
        prev = next = new_element;
268
162k
      } else {
269
162k
        new_element->next = next;
270
271
162k
        if (current) { // not extracted
272
162k
          current->next = new_element;
273
162k
          prev = current;
274
162k
          if (current == list->last) {
275
162k
            list->last = new_element;
276
162k
          }
277
162k
        } 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
162k
      }
287
178k
      current = new_element;
288
178k
    } // 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.1M
      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.1M
      if (list->empty()) {
310
18.0M
        new_element->next = new_element;
311
18.0M
        list->last = new_element;
312
18.0M
        prev = next = new_element;
313
18.0M
        ex_current_was_last = false;
314
18.0M
        current = nullptr;
315
18.0M
      } else {
316
3.10M
        new_element->next = next;
317
318
3.10M
        if (current) { // not extracted
319
3.10M
          current->next = new_element;
320
3.10M
          if (prev == current) {
321
2.52M
            prev = new_element;
322
2.52M
          }
323
3.10M
          if (current == list->last) {
324
2.86M
            list->last = new_element;
325
2.86M
          }
326
3.10M
        } 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
3.10M
        next = new_element;
334
3.10M
      }
335
21.1M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_after_stay_put(tesseract::C_BLOB*)
Line
Count
Source
296
120k
      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
120k
      if (list->empty()) {
310
120k
        new_element->next = new_element;
311
120k
        list->last = new_element;
312
120k
        prev = next = new_element;
313
120k
        ex_current_was_last = false;
314
120k
        current = nullptr;
315
120k
      } 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
120k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_after_stay_put(tesseract::BLOCK*)
Line
Count
Source
296
16.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
16.2k
      if (list->empty()) {
310
16.2k
        new_element->next = new_element;
311
16.2k
        list->last = new_element;
312
16.2k
        prev = next = new_element;
313
16.2k
        ex_current_was_last = false;
314
16.2k
        current = nullptr;
315
16.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
16.2k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_after_stay_put(tesseract::WERD_RES*)
Line
Count
Source
296
140k
      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
140k
      if (list->empty()) {
310
140k
        new_element->next = new_element;
311
140k
        list->last = new_element;
312
140k
        prev = next = new_element;
313
140k
        ex_current_was_last = false;
314
140k
        current = nullptr;
315
140k
      } 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
140k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_after_stay_put(tesseract::BLOBNBOX*)
Line
Count
Source
296
1.32M
      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.32M
      if (list->empty()) {
310
750k
        new_element->next = new_element;
311
750k
        list->last = new_element;
312
750k
        prev = next = new_element;
313
750k
        ex_current_was_last = false;
314
750k
        current = nullptr;
315
750k
      } else {
316
569k
        new_element->next = next;
317
318
569k
        if (current) { // not extracted
319
569k
          current->next = new_element;
320
569k
          if (prev == current) {
321
324k
            prev = new_element;
322
324k
          }
323
569k
          if (current == list->last) {
324
337k
            list->last = new_element;
325
337k
          }
326
569k
        } 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
569k
        next = new_element;
334
569k
      }
335
1.32M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_after_stay_put(tesseract::C_OUTLINE*)
Line
Count
Source
296
7.49M
      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
7.49M
      if (list->empty()) {
310
6.93M
        new_element->next = new_element;
311
6.93M
        list->last = new_element;
312
6.93M
        prev = next = new_element;
313
6.93M
        ex_current_was_last = false;
314
6.93M
        current = nullptr;
315
6.93M
      } else {
316
564k
        new_element->next = next;
317
318
564k
        if (current) { // not extracted
319
564k
          current->next = new_element;
320
564k
          if (prev == current) {
321
564k
            prev = new_element;
322
564k
          }
323
564k
          if (current == list->last) {
324
564k
            list->last = new_element;
325
564k
          }
326
564k
        } 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
564k
        next = new_element;
334
564k
      }
335
7.49M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_after_stay_put(tesseract::ICOORDELT*)
Line
Count
Source
296
567k
      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
567k
      if (list->empty()) {
310
567k
        new_element->next = new_element;
311
567k
        list->last = new_element;
312
567k
        prev = next = new_element;
313
567k
        ex_current_was_last = false;
314
567k
        current = nullptr;
315
567k
      } 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
567k
    } // 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
14.4k
      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
14.4k
      if (list->empty()) {
310
14.4k
        new_element->next = new_element;
311
14.4k
        list->last = new_element;
312
14.4k
        prev = next = new_element;
313
14.4k
        ex_current_was_last = false;
314
14.4k
        current = nullptr;
315
14.4k
      } 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
14.4k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::add_after_stay_put(tesseract::ROW_RES*)
Line
Count
Source
296
14.4k
      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
14.4k
      if (list->empty()) {
310
14.4k
        new_element->next = new_element;
311
14.4k
        list->last = new_element;
312
14.4k
        prev = next = new_element;
313
14.4k
        ex_current_was_last = false;
314
14.4k
        current = nullptr;
315
14.4k
      } 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
14.4k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_after_stay_put(tesseract::WERD_CHOICE*)
Line
Count
Source
296
320k
      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
320k
      if (list->empty()) {
310
271k
        new_element->next = new_element;
311
271k
        list->last = new_element;
312
271k
        prev = next = new_element;
313
271k
        ex_current_was_last = false;
314
271k
        current = nullptr;
315
271k
      } else {
316
48.7k
        new_element->next = next;
317
318
48.7k
        if (current) { // not extracted
319
48.7k
          current->next = new_element;
320
48.7k
          if (prev == current) {
321
48.7k
            prev = new_element;
322
48.7k
          }
323
48.7k
          if (current == list->last) {
324
48.7k
            list->last = new_element;
325
48.7k
          }
326
48.7k
        } 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
48.7k
        next = new_element;
334
48.7k
      }
335
320k
    } // 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.09M
        new_element->next = new_element;
311
9.09M
        list->last = new_element;
312
9.09M
        prev = next = new_element;
313
9.09M
        ex_current_was_last = false;
314
9.09M
        current = nullptr;
315
9.09M
      } else {
316
1.57M
        new_element->next = next;
317
318
1.57M
        if (current) { // not extracted
319
1.57M
          current->next = new_element;
320
1.57M
          if (prev == current) {
321
1.52M
            prev = new_element;
322
1.52M
          }
323
1.57M
          if (current == list->last) {
324
1.57M
            list->last = new_element;
325
1.57M
          }
326
1.57M
        } 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.57M
        next = new_element;
334
1.57M
      }
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
104k
      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
104k
      if (list->empty()) {
310
65.1k
        new_element->next = new_element;
311
65.1k
        list->last = new_element;
312
65.1k
        prev = next = new_element;
313
65.1k
        ex_current_was_last = false;
314
65.1k
        current = nullptr;
315
65.1k
      } else {
316
39.5k
        new_element->next = next;
317
318
39.5k
        if (current) { // not extracted
319
39.5k
          current->next = new_element;
320
39.5k
          if (prev == current) {
321
39.5k
            prev = new_element;
322
39.5k
          }
323
39.5k
          if (current == list->last) {
324
39.5k
            list->last = new_element;
325
39.5k
          }
326
39.5k
        } 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
39.5k
        next = new_element;
334
39.5k
      }
335
104k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::add_after_stay_put(tesseract::SORTED_FLOAT*)
Line
Count
Source
296
375k
      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
375k
      if (list->empty()) {
310
69.4k
        new_element->next = new_element;
311
69.4k
        list->last = new_element;
312
69.4k
        prev = next = new_element;
313
69.4k
        ex_current_was_last = false;
314
69.4k
        current = nullptr;
315
306k
      } else {
316
306k
        new_element->next = next;
317
318
306k
        if (current) { // not extracted
319
306k
          current->next = new_element;
320
306k
          if (prev == current) {
321
25.5k
            prev = new_element;
322
25.5k
          }
323
306k
          if (current == list->last) {
324
306k
            list->last = new_element;
325
306k
          }
326
306k
        } 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
306k
        next = new_element;
334
306k
      }
335
375k
    } // 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.34M
      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.34M
      if (list->empty()) {
357
67.7k
        new_element->next = new_element;
358
67.7k
        list->last = new_element;
359
67.7k
        prev = next = new_element;
360
5.27M
      } else {
361
5.27M
        prev->next = new_element;
362
5.27M
        if (current) { // not extracted
363
5.27M
          new_element->next = current;
364
5.27M
          next = current;
365
5.27M
        } 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.27M
      }
375
5.34M
      current = new_element;
376
5.34M
    } // 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.02k
      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.02k
      if (list->empty()) {
357
835
        new_element->next = new_element;
358
835
        list->last = new_element;
359
835
        prev = next = new_element;
360
835
      } else {
361
192
        prev->next = new_element;
362
192
        if (current) { // not extracted
363
192
          new_element->next = current;
364
192
          next = current;
365
192
        } 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
192
      }
375
1.02k
      current = new_element;
376
1.02k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::Iterator::add_before_then_move(tesseract::ViterbiStateEntry*)
Line
Count
Source
343
4.28M
      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.28M
      if (list->empty()) {
357
0
        new_element->next = new_element;
358
0
        list->last = new_element;
359
0
        prev = next = new_element;
360
4.28M
      } else {
361
4.28M
        prev->next = new_element;
362
4.28M
        if (current) { // not extracted
363
4.28M
          new_element->next = current;
364
4.28M
          next = current;
365
4.28M
        } 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.28M
      }
375
4.28M
      current = new_element;
376
4.28M
    } // 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
95.0k
      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
95.0k
      if (list->empty()) {
357
0
        new_element->next = new_element;
358
0
        list->last = new_element;
359
0
        prev = next = new_element;
360
95.0k
      } else {
361
95.0k
        prev->next = new_element;
362
95.0k
        if (current) { // not extracted
363
95.0k
          new_element->next = current;
364
95.0k
          next = current;
365
95.0k
        } 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
95.0k
      }
375
95.0k
      current = new_element;
376
95.0k
    } // move to new
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::add_before_then_move(tesseract::FPSEGPT*)
Line
Count
Source
343
884k
      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
884k
      if (list->empty()) {
357
66.8k
        new_element->next = new_element;
358
66.8k
        list->last = new_element;
359
66.8k
        prev = next = new_element;
360
817k
      } else {
361
817k
        prev->next = new_element;
362
817k
        if (current) { // not extracted
363
817k
          new_element->next = current;
364
817k
          next = current;
365
817k
        } 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
817k
      }
375
884k
      current = new_element;
376
884k
    } // 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.9M
      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.9M
      if (list->empty()) {
398
20.6k
        new_element->next = new_element;
399
20.6k
        list->last = new_element;
400
20.6k
        prev = next = new_element;
401
20.6k
        ex_current_was_last = true;
402
20.6k
        current = nullptr;
403
25.8M
      } else {
404
25.8M
        prev->next = new_element;
405
25.8M
        if (current) { // not extracted
406
10.1M
          new_element->next = current;
407
10.1M
          if (next == current) {
408
77.0k
            next = new_element;
409
77.0k
          }
410
15.7M
        } else { // current extracted
411
15.7M
          new_element->next = next;
412
15.7M
          if (ex_current_was_last) {
413
2.27k
            list->last = new_element;
414
2.27k
          }
415
15.7M
        }
416
25.8M
        prev = new_element;
417
25.8M
      }
418
25.9M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_before_stay_put(tesseract::C_BLOB*)
Line
Count
Source
384
473k
      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
473k
      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
473k
      } else {
404
473k
        prev->next = new_element;
405
473k
        if (current) { // not extracted
406
0
          new_element->next = current;
407
0
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
473k
        } else { // current extracted
411
473k
          new_element->next = next;
412
473k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
473k
        }
416
473k
        prev = new_element;
417
473k
      }
418
473k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_before_stay_put(tesseract::BLOB_CHOICE*)
Line
Count
Source
384
9.53M
      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
9.53M
      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
9.53M
      } else {
404
9.53M
        prev->next = new_element;
405
9.53M
        if (current) { // not extracted
406
2.69M
          new_element->next = current;
407
2.69M
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
6.83M
        } else { // current extracted
411
6.83M
          new_element->next = next;
412
6.83M
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
6.83M
        }
416
9.53M
        prev = new_element;
417
9.53M
      }
418
9.53M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_before_stay_put(tesseract::C_OUTLINE*)
Line
Count
Source
384
2.22M
      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.22M
      if (list->empty()) {
398
20.6k
        new_element->next = new_element;
399
20.6k
        list->last = new_element;
400
20.6k
        prev = next = new_element;
401
20.6k
        ex_current_was_last = true;
402
20.6k
        current = nullptr;
403
2.20M
      } else {
404
2.20M
        prev->next = new_element;
405
2.20M
        if (current) { // not extracted
406
2.12M
          new_element->next = current;
407
2.12M
          if (next == current) {
408
622
            next = new_element;
409
622
          }
410
2.12M
        } else { // current extracted
411
81.9k
          new_element->next = next;
412
81.9k
          if (ex_current_was_last) {
413
2.27k
            list->last = new_element;
414
2.27k
          }
415
81.9k
        }
416
2.20M
        prev = new_element;
417
2.20M
      }
418
2.22M
    } // 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
315k
      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
315k
      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
315k
      } else {
404
315k
        prev->next = new_element;
405
315k
        if (current) { // not extracted
406
127k
          new_element->next = current;
407
127k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
187k
        } else { // current extracted
411
187k
          new_element->next = next;
412
187k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
187k
        }
416
315k
        prev = new_element;
417
315k
      }
418
315k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_before_stay_put(tesseract::BLOBNBOX*)
Line
Count
Source
384
11.0M
      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.0M
      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.0M
      } else {
404
11.0M
        prev->next = new_element;
405
11.0M
        if (current) { // not extracted
406
3.61M
          new_element->next = current;
407
3.61M
          if (next == current) {
408
147
            next = new_element;
409
147
          }
410
7.45M
        } else { // current extracted
411
7.45M
          new_element->next = next;
412
7.45M
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
7.45M
        }
416
11.0M
        prev = new_element;
417
11.0M
      }
418
11.0M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_before_stay_put(tesseract::ICOORDELT*)
Line
Count
Source
384
656k
      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
656k
      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
656k
      } else {
404
656k
        prev->next = new_element;
405
656k
        if (current) { // not extracted
406
64.8k
          new_element->next = current;
407
64.8k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
591k
        } else { // current extracted
411
591k
          new_element->next = next;
412
591k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
591k
        }
416
656k
        prev = new_element;
417
656k
      }
418
656k
    } // 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
126k
      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
126k
      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
126k
      } else {
404
126k
        prev->next = new_element;
405
126k
        if (current) { // not extracted
406
0
          new_element->next = current;
407
0
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
126k
        } else { // current extracted
411
126k
          new_element->next = next;
412
126k
          if (ex_current_was_last) {
413
0
            list->last = new_element;
414
0
          }
415
126k
        }
416
126k
        prev = new_element;
417
126k
      }
418
126k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_before_stay_put(tesseract::WERD_CHOICE*)
Line
Count
Source
384
558k
      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
558k
      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
558k
      } else {
404
558k
        prev->next = new_element;
405
558k
        if (current) { // not extracted
406
558k
          new_element->next = current;
407
558k
          if (next == current) {
408
34.1k
            next = new_element;
409
34.1k
          }
410
558k
        } 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
558k
        prev = new_element;
417
558k
      }
418
558k
    } // 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
34.8k
      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
34.8k
      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
34.8k
      } else {
404
34.8k
        prev->next = new_element;
405
34.8k
        if (current) { // not extracted
406
34.8k
          new_element->next = current;
407
34.8k
          if (next == current) {
408
0
            next = new_element;
409
0
          }
410
34.8k
        } 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
34.8k
        prev = new_element;
417
34.8k
      }
418
34.8k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::add_before_stay_put(tesseract::SORTED_FLOAT*)
Line
Count
Source
384
913k
      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
913k
      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
913k
      } else {
404
913k
        prev->next = new_element;
405
913k
        if (current) { // not extracted
406
913k
          new_element->next = current;
407
913k
          if (next == current) {
408
42.1k
            next = new_element;
409
42.1k
          }
410
913k
        } 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
913k
        prev = new_element;
417
913k
      }
418
913k
    } // 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.30M
      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.30M
      if (!list_to_add->empty()) {
438
2.26M
        if (list->empty()) {
439
699k
          list->last = list_to_add->last;
440
699k
          prev = list->last;
441
699k
          next = list->First();
442
699k
          ex_current_was_last = true;
443
699k
          current = nullptr;
444
1.56M
        } else {
445
1.56M
          if (current) { // not extracted
446
1.38M
            current->next = list_to_add->First();
447
1.38M
            if (current == list->last) {
448
1.26M
              list->last = list_to_add->last;
449
1.26M
            }
450
1.38M
            list_to_add->last->next = next;
451
1.38M
            next = current->next;
452
1.38M
          } else { // current extracted
453
179k
            prev->next = list_to_add->First();
454
179k
            if (ex_current_was_last) {
455
16.9k
              list->last = list_to_add->last;
456
16.9k
              ex_current_was_last = false;
457
16.9k
            }
458
179k
            list_to_add->last->next = next;
459
179k
            next = prev->next;
460
179k
          }
461
1.56M
        }
462
2.26M
        list_to_add->last = nullptr;
463
2.26M
      }
464
2.30M
    } // 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
128k
      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
128k
      if (!list_to_add->empty()) {
438
125k
        if (list->empty()) {
439
107k
          list->last = list_to_add->last;
440
107k
          prev = list->last;
441
107k
          next = list->First();
442
107k
          ex_current_was_last = true;
443
107k
          current = nullptr;
444
107k
        } else {
445
17.6k
          if (current) { // not extracted
446
17.6k
            current->next = list_to_add->First();
447
17.6k
            if (current == list->last) {
448
17.6k
              list->last = list_to_add->last;
449
17.6k
            }
450
17.6k
            list_to_add->last->next = next;
451
17.6k
            next = current->next;
452
17.6k
          } 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.6k
        }
462
125k
        list_to_add->last = nullptr;
463
125k
      }
464
128k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
427
1.19M
      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.19M
      if (!list_to_add->empty()) {
438
1.19M
        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.19M
        } else {
445
1.19M
          if (current) { // not extracted
446
1.19M
            current->next = list_to_add->First();
447
1.19M
            if (current == list->last) {
448
1.19M
              list->last = list_to_add->last;
449
1.19M
            }
450
1.19M
            list_to_add->last->next = next;
451
1.19M
            next = current->next;
452
1.19M
          } 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.19M
        }
462
1.19M
        list_to_add->last = nullptr;
463
1.19M
      }
464
1.19M
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>*)
Line
Count
Source
427
371k
      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
371k
      if (!list_to_add->empty()) {
438
342k
        if (list->empty()) {
439
29.7k
          list->last = list_to_add->last;
440
29.7k
          prev = list->last;
441
29.7k
          next = list->First();
442
29.7k
          ex_current_was_last = true;
443
29.7k
          current = nullptr;
444
313k
        } else {
445
313k
          if (current) { // not extracted
446
133k
            current->next = list_to_add->First();
447
133k
            if (current == list->last) {
448
8.67k
              list->last = list_to_add->last;
449
8.67k
            }
450
133k
            list_to_add->last->next = next;
451
133k
            next = current->next;
452
179k
          } else { // current extracted
453
179k
            prev->next = list_to_add->First();
454
179k
            if (ex_current_was_last) {
455
16.9k
              list->last = list_to_add->last;
456
16.9k
              ex_current_was_last = false;
457
16.9k
            }
458
179k
            list_to_add->last->next = next;
459
179k
            next = prev->next;
460
179k
          }
461
313k
        }
462
342k
        list_to_add->last = nullptr;
463
342k
      }
464
371k
    } // stay at current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_list_after(tesseract::IntrusiveForwardList<tesseract::C_BLOB>*)
Line
Count
Source
427
594k
      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
594k
      if (!list_to_add->empty()) {
438
593k
        if (list->empty()) {
439
547k
          list->last = list_to_add->last;
440
547k
          prev = list->last;
441
547k
          next = list->First();
442
547k
          ex_current_was_last = true;
443
547k
          current = nullptr;
444
547k
        } else {
445
45.8k
          if (current) { // not extracted
446
45.8k
            current->next = list_to_add->First();
447
45.8k
            if (current == list->last) {
448
45.8k
              list->last = list_to_add->last;
449
45.8k
            }
450
45.8k
            list_to_add->last->next = next;
451
45.8k
            next = current->next;
452
45.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
45.8k
        }
462
593k
        list_to_add->last = nullptr;
463
593k
      }
464
594k
    } // 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.3k
      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.3k
      if (!list_to_add->empty()) {
438
14.3k
        if (list->empty()) {
439
14.3k
          list->last = list_to_add->last;
440
14.3k
          prev = list->last;
441
14.3k
          next = list->First();
442
14.3k
          ex_current_was_last = true;
443
14.3k
          current = nullptr;
444
14.3k
        } 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.3k
        list_to_add->last = nullptr;
463
14.3k
      }
464
14.3k
    } // 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
109k
      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
109k
      if (!list_to_add->empty()) {
484
89.9k
        if (list->empty()) {
485
30.8k
          list->last = list_to_add->last;
486
30.8k
          prev = list->last;
487
30.8k
          current = list->First();
488
30.8k
          next = current->next;
489
30.8k
          ex_current_was_last = false;
490
59.0k
        } else {
491
59.0k
          prev->next = list_to_add->First();
492
59.0k
          if (current) { // not extracted
493
59.0k
            list_to_add->last->next = current;
494
59.0k
          } 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
59.0k
          current = prev->next;
504
59.0k
          next = current->next;
505
59.0k
        }
506
89.9k
        list_to_add->last = nullptr;
507
89.9k
      }
508
109k
    } // 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
59.0k
      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
59.0k
      if (!list_to_add->empty()) {
484
59.0k
        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
59.0k
        } else {
491
59.0k
          prev->next = list_to_add->First();
492
59.0k
          if (current) { // not extracted
493
59.0k
            list_to_add->last->next = current;
494
59.0k
          } 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
59.0k
          current = prev->next;
504
59.0k
          next = current->next;
505
59.0k
        }
506
59.0k
        list_to_add->last = nullptr;
507
59.0k
      }
508
59.0k
    } // move to it 1st item
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_list_before(tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>*)
Line
Count
Source
473
50.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
50.1k
      if (!list_to_add->empty()) {
484
30.8k
        if (list->empty()) {
485
30.8k
          list->last = list_to_add->last;
486
30.8k
          prev = list->last;
487
30.8k
          current = list->First();
488
30.8k
          next = current->next;
489
30.8k
          ex_current_was_last = false;
490
30.8k
        } 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
30.8k
        list_to_add->last = nullptr;
507
30.8k
      }
508
50.1k
    } // move to it 1st item
509
510
2.79G
    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.79G
      return current;
520
2.79G
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::data()
Line
Count
Source
510
91.9k
    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
91.9k
      return current;
520
91.9k
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::data()
Line
Count
Source
510
299M
    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
299M
      return current;
520
299M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::data()
Line
Count
Source
510
9.27M
    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
9.27M
      return current;
520
9.27M
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::data()
Line
Count
Source
510
116M
    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
116M
      return current;
520
116M
    }
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::data()
Line
Count
Source
510
764k
    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
764k
      return current;
520
764k
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::data()
Line
Count
Source
510
150M
    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
150M
      return current;
520
150M
    }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::data()
Line
Count
Source
510
229M
    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
229M
      return current;
520
229M
    }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::data()
Line
Count
Source
510
560M
    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
560M
      return current;
520
560M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::data()
Line
Count
Source
510
15.0M
    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.0M
      return current;
520
15.0M
    }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::data()
Line
Count
Source
510
443k
    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
443k
      return current;
520
443k
    }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::data()
Line
Count
Source
510
117M
    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
117M
      return current;
520
117M
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::data()
Line
Count
Source
510
194M
    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
194M
      return current;
520
194M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::data()
Line
Count
Source
510
316M
    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
316M
      return current;
520
316M
    }
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
773M
    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
773M
      return current;
520
773M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::data()
Line
Count
Source
510
900k
    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
900k
      return current;
520
900k
    }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::data()
Line
Count
Source
510
7.47M
    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.47M
      return current;
520
7.47M
    }
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
11.3M
      int8_t offset) {                       // offset from current
530
11.3M
      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
11.3M
      if (offset == -1) {
542
7.55M
        ptr = prev;
543
7.55M
      } else {
544
9.37M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
5.58M
        }
546
3.78M
      }
547
548
#ifndef NDEBUG
549
      if (!ptr)
550
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
551
#endif
552
553
11.3M
      return ptr;
554
11.3M
    }        // 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
12.3k
      int8_t offset) {                       // offset from current
530
12.3k
      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.3k
      if (offset == -1) {
542
0
        ptr = prev;
543
12.3k
      } else {
544
24.7k
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
12.3k
        }
546
12.3k
      }
547
548
#ifndef NDEBUG
549
      if (!ptr)
550
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
551
#endif
552
553
12.3k
      return ptr;
554
12.3k
    }        // offset from current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::data_relative(signed char)
Line
Count
Source
529
2.77M
      int8_t offset) {                       // offset from current
530
2.77M
      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
2.77M
      if (offset == -1) {
542
2.48M
        ptr = prev;
543
2.48M
      } else {
544
587k
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
293k
        }
546
293k
      }
547
548
#ifndef NDEBUG
549
      if (!ptr)
550
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
551
#endif
552
553
2.77M
      return ptr;
554
2.77M
    }        // 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
7.65M
      int8_t offset) {                       // offset from current
530
7.65M
      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
7.65M
      if (offset == -1) {
542
5.06M
        ptr = prev;
543
5.06M
      } else {
544
5.16M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
2.58M
        }
546
2.58M
      }
547
548
#ifndef NDEBUG
549
      if (!ptr)
550
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
551
#endif
552
553
7.65M
      return ptr;
554
7.65M
    }        // offset from current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::data_relative(signed char)
Line
Count
Source
529
901k
      int8_t offset) {                       // offset from current
530
901k
      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
901k
      if (offset == -1) {
542
0
        ptr = prev;
543
901k
      } else {
544
3.60M
        for (ptr = current ? current : prev; offset-- > 0; ptr = ptr->next) {
545
2.70M
        }
546
901k
      }
547
548
#ifndef NDEBUG
549
      if (!ptr)
550
        NULL_DATA.error("ELIST_ITERATOR::data_relative", ABORT);
551
#endif
552
553
901k
      return ptr;
554
901k
    }        // offset from current
555
      /***********************************************************************
556
     *              ELIST_ITERATOR::forward
557
     *
558
     *  Move the iterator to the next element of the list.
559
     *  REMEMBER: ALL LISTS ARE CIRCULAR.
560
     **********************************************************************/
561
2.39G
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
2.39G
      if (list->empty()) {
567
7.22M
        return nullptr;
568
7.22M
      }
569
570
2.38G
      if (current) { // not removed so
571
        // set previous
572
2.36G
        prev = current;
573
2.36G
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
2.36G
        current = current->next;
576
2.36G
      } else {
577
23.8M
        if (ex_current_was_cycle_pt) {
578
17.0M
          cycle_pt = next;
579
17.0M
        }
580
23.8M
        current = next;
581
23.8M
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
2.38G
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
2.38G
      return current;
597
2.39G
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::forward()
Line
Count
Source
561
91.9k
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
91.9k
      if (list->empty()) {
567
1.76k
        return nullptr;
568
1.76k
      }
569
570
90.1k
      if (current) { // not removed so
571
        // set previous
572
90.1k
        prev = current;
573
90.1k
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
90.1k
        current = current->next;
576
90.1k
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
90.1k
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
90.1k
      return current;
597
91.9k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::forward()
Line
Count
Source
561
324M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
324M
      if (list->empty()) {
567
6.36M
        return nullptr;
568
6.36M
      }
569
570
317M
      if (current) { // not removed so
571
        // set previous
572
313M
        prev = current;
573
313M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
313M
        current = current->next;
576
313M
      } else {
577
4.00M
        if (ex_current_was_cycle_pt) {
578
3.45M
          cycle_pt = next;
579
3.45M
        }
580
4.00M
        current = next;
581
4.00M
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
317M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
317M
      return current;
597
324M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::forward()
Line
Count
Source
561
277M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
277M
      if (list->empty()) {
567
303k
        return nullptr;
568
303k
      }
569
570
277M
      if (current) { // not removed so
571
        // set previous
572
262M
        prev = current;
573
262M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
262M
        current = current->next;
576
262M
      } else {
577
14.7M
        if (ex_current_was_cycle_pt) {
578
9.91M
          cycle_pt = next;
579
9.91M
        }
580
14.7M
        current = next;
581
14.7M
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
277M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
277M
      return current;
597
277M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::forward()
Line
Count
Source
561
598k
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
598k
      if (list->empty()) {
567
1.26k
        return nullptr;
568
1.26k
      }
569
570
597k
      if (current) { // not removed so
571
        // set previous
572
560k
        prev = current;
573
560k
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
560k
        current = current->next;
576
560k
      } else {
577
36.4k
        if (ex_current_was_cycle_pt) {
578
11.7k
          cycle_pt = next;
579
11.7k
        }
580
36.4k
        current = next;
581
36.4k
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
597k
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
597k
      return current;
597
598k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::forward()
Line
Count
Source
561
153M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
153M
      if (list->empty()) {
567
268k
        return nullptr;
568
268k
      }
569
570
152M
      if (current) { // not removed so
571
        // set previous
572
149M
        prev = current;
573
149M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
149M
        current = current->next;
576
149M
      } else {
577
3.92M
        if (ex_current_was_cycle_pt) {
578
3.40M
          cycle_pt = next;
579
3.40M
        }
580
3.92M
        current = next;
581
3.92M
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
152M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
152M
      return current;
597
153M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::forward()
Line
Count
Source
561
82.1M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
82.1M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
82.1M
      if (current) { // not removed so
571
        // set previous
572
82.1M
        prev = current;
573
82.1M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
82.1M
        current = current->next;
576
82.1M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
82.1M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
82.1M
      return current;
597
82.1M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::forward()
Line
Count
Source
561
544M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
544M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
544M
      if (current) { // not removed so
571
        // set previous
572
544M
        prev = current;
573
544M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
544M
        current = current->next;
576
544M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
544M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
544M
      return current;
597
544M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::forward()
Line
Count
Source
561
14.9M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
14.9M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
14.9M
      if (current) { // not removed so
571
        // set previous
572
14.4M
        prev = current;
573
14.4M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
14.4M
        current = current->next;
576
14.4M
      } else {
577
459k
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
459k
        current = next;
581
459k
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
14.9M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
14.9M
      return current;
597
14.9M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::forward()
Line
Count
Source
561
3.10M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
3.10M
      if (list->empty()) {
567
281k
        return nullptr;
568
281k
      }
569
570
2.81M
      if (current) { // not removed so
571
        // set previous
572
2.24M
        prev = current;
573
2.24M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
2.24M
        current = current->next;
576
2.24M
      } else {
577
570k
        if (ex_current_was_cycle_pt) {
578
309k
          cycle_pt = next;
579
309k
        }
580
570k
        current = next;
581
570k
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
2.81M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
2.81M
      return current;
597
3.10M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::forward()
Line
Count
Source
561
1.73M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
1.73M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
1.73M
      if (current) { // not removed so
571
        // set previous
572
1.73M
        prev = current;
573
1.73M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
1.73M
        current = current->next;
576
1.73M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
1.73M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
1.73M
      return current;
597
1.73M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::forward()
Line
Count
Source
561
75.2M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
75.2M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
75.2M
      if (current) { // not removed so
571
        // set previous
572
75.2M
        prev = current;
573
75.2M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
75.2M
        current = current->next;
576
75.2M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
75.2M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
75.2M
      return current;
597
75.2M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::forward()
Line
Count
Source
561
204M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
204M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
204M
      if (current) { // not removed so
571
        // set previous
572
204M
        prev = current;
573
204M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
204M
        current = current->next;
576
204M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
204M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
204M
      return current;
597
204M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::forward()
Line
Count
Source
561
362k
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
362k
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
362k
      if (current) { // not removed so
571
        // set previous
572
362k
        prev = current;
573
362k
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
362k
        current = current->next;
576
362k
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
362k
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
362k
      return current;
597
362k
    } // 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
561
704M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
704M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
704M
      if (current) { // not removed so
571
        // set previous
572
704M
        prev = current;
573
704M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
704M
        current = current->next;
576
704M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
704M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
704M
      return current;
597
704M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::forward()
Line
Count
Source
561
461k
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
461k
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
461k
      if (current) { // not removed so
571
        // set previous
572
344k
        prev = current;
573
344k
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
344k
        current = current->next;
576
344k
      } else {
577
117k
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
117k
        current = next;
581
117k
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
461k
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
461k
      return current;
597
461k
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::forward()
Line
Count
Source
561
4.58M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
4.58M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
4.58M
      if (current) { // not removed so
571
        // set previous
572
4.58M
        prev = current;
573
4.58M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
4.58M
        current = current->next;
576
4.58M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
4.58M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
4.58M
      return current;
597
4.58M
    } // move to next element
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::forward()
Line
Count
Source
561
1.70M
    T *forward() {
562
#ifndef NDEBUG
563
      if (!list)
564
        NO_LIST.error("ELIST_ITERATOR::forward", ABORT);
565
#endif
566
1.70M
      if (list->empty()) {
567
0
        return nullptr;
568
0
      }
569
570
1.70M
      if (current) { // not removed so
571
        // set previous
572
1.70M
        prev = current;
573
1.70M
        started_cycling = true;
574
        // In case next is deleted by another iterator, get next from current.
575
1.70M
        current = current->next;
576
1.70M
      } else {
577
0
        if (ex_current_was_cycle_pt) {
578
0
          cycle_pt = next;
579
0
        }
580
0
        current = next;
581
0
      }
582
#ifndef NDEBUG
583
      if (!current)
584
        NULL_DATA.error("ELIST_ITERATOR::forward", ABORT);
585
#endif
586
1.70M
      next = current->next;
587
588
#ifndef NDEBUG
589
      if (!next) {
590
        NULL_NEXT.error("ELIST_ITERATOR::forward", ABORT,
591
          "This is: %p  Current is: %p",
592
          static_cast<void *>(this),
593
          static_cast<void *>(current));
594
      }
595
#endif
596
1.70M
      return current;
597
1.70M
    } // move to next element
598
599
      /***********************************************************************
600
     *                          ELIST_ITERATOR::extract
601
     *
602
     *  Do extraction by removing current from the list, returning it to the
603
     *  caller, but NOT updating the iterator.  (So that any calling loop can do
604
     *  this.)   The iterator's current points to nullptr.  If the extracted element
605
     *  is to be deleted, this is the callers responsibility.
606
     **********************************************************************/
607
35.0M
    T *extract() {
608
35.0M
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
35.0M
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
7.81M
        prev = next = list->last = nullptr;
623
27.1M
      } else {
624
27.1M
        prev->next = next; // remove from list
625
626
27.1M
        ex_current_was_last = (current == list->last);
627
27.1M
        if (ex_current_was_last) {
628
1.04M
          list->last = prev;
629
1.04M
        }
630
27.1M
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
35.0M
      ex_current_was_cycle_pt = (current == cycle_pt);
633
35.0M
      extracted_link = current;
634
35.0M
      extracted_link->next = nullptr; // for safety
635
35.0M
      current = nullptr;
636
35.0M
      return extracted_link;
637
35.0M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::extract()
Line
Count
Source
607
4.18M
    T *extract() {
608
4.18M
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
4.18M
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
268k
        prev = next = list->last = nullptr;
623
3.92M
      } else {
624
3.92M
        prev->next = next; // remove from list
625
626
3.92M
        ex_current_was_last = (current == list->last);
627
3.92M
        if (ex_current_was_last) {
628
13.1k
          list->last = prev;
629
13.1k
        }
630
3.92M
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
4.18M
      ex_current_was_cycle_pt = (current == cycle_pt);
633
4.18M
      extracted_link = current;
634
4.18M
      extracted_link->next = nullptr; // for safety
635
4.18M
      current = nullptr;
636
4.18M
      return extracted_link;
637
4.18M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::extract()
Line
Count
Source
607
13.1M
    T *extract() {
608
13.1M
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
13.1M
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
6.89M
        prev = next = list->last = nullptr;
623
6.89M
      } else {
624
6.27M
        prev->next = next; // remove from list
625
626
6.27M
        ex_current_was_last = (current == list->last);
627
6.27M
        if (ex_current_was_last) {
628
72.1k
          list->last = prev;
629
72.1k
        }
630
6.27M
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
13.1M
      ex_current_was_cycle_pt = (current == cycle_pt);
633
13.1M
      extracted_link = current;
634
13.1M
      extracted_link->next = nullptr; // for safety
635
13.1M
      current = nullptr;
636
13.1M
      return extracted_link;
637
13.1M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::extract()
Line
Count
Source
607
115k
    T *extract() {
608
115k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
115k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
4
        prev = next = list->last = nullptr;
623
115k
      } else {
624
115k
        prev->next = next; // remove from list
625
626
115k
        ex_current_was_last = (current == list->last);
627
115k
        if (ex_current_was_last) {
628
5.43k
          list->last = prev;
629
5.43k
        }
630
115k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
115k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
115k
      extracted_link = current;
634
115k
      extracted_link->next = nullptr; // for safety
635
115k
      current = nullptr;
636
115k
      return extracted_link;
637
115k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::extract()
Line
Count
Source
607
15.0M
    T *extract() {
608
15.0M
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
15.0M
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
303k
        prev = next = list->last = nullptr;
623
14.7M
      } else {
624
14.7M
        prev->next = next; // remove from list
625
626
14.7M
        ex_current_was_last = (current == list->last);
627
14.7M
        if (ex_current_was_last) {
628
35.7k
          list->last = prev;
629
35.7k
        }
630
14.7M
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
15.0M
      ex_current_was_cycle_pt = (current == cycle_pt);
633
15.0M
      extracted_link = current;
634
15.0M
      extracted_link->next = nullptr; // for safety
635
15.0M
      current = nullptr;
636
15.0M
      return extracted_link;
637
15.0M
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::extract()
Line
Count
Source
607
37.6k
    T *extract() {
608
37.6k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
37.6k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
1.26k
        prev = next = list->last = nullptr;
623
36.4k
      } else {
624
36.4k
        prev->next = next; // remove from list
625
626
36.4k
        ex_current_was_last = (current == list->last);
627
36.4k
        if (ex_current_was_last) {
628
2.52k
          list->last = prev;
629
2.52k
        }
630
36.4k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
37.6k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
37.6k
      extracted_link = current;
634
37.6k
      extracted_link->next = nullptr; // for safety
635
37.6k
      current = nullptr;
636
37.6k
      return extracted_link;
637
37.6k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::extract()
Line
Count
Source
607
459k
    T *extract() {
608
459k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
459k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
0
        prev = next = list->last = nullptr;
623
459k
      } else {
624
459k
        prev->next = next; // remove from list
625
626
459k
        ex_current_was_last = (current == list->last);
627
459k
        if (ex_current_was_last) {
628
260k
          list->last = prev;
629
260k
        }
630
459k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
459k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
459k
      extracted_link = current;
634
459k
      extracted_link->next = nullptr; // for safety
635
459k
      current = nullptr;
636
459k
      return extracted_link;
637
459k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::extract()
Line
Count
Source
607
852k
    T *extract() {
608
852k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
852k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
281k
        prev = next = list->last = nullptr;
623
570k
      } else {
624
570k
        prev->next = next; // remove from list
625
626
570k
        ex_current_was_last = (current == list->last);
627
570k
        if (ex_current_was_last) {
628
261k
          list->last = prev;
629
261k
        }
630
570k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
852k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
852k
      extracted_link = current;
634
852k
      extracted_link->next = nullptr; // for safety
635
852k
      current = nullptr;
636
852k
      return extracted_link;
637
852k
    }  // 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
607
1.76k
    T *extract() {
608
1.76k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
1.76k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
1.76k
        prev = next = list->last = nullptr;
623
1.76k
      } else {
624
0
        prev->next = next; // remove from list
625
626
0
        ex_current_was_last = (current == list->last);
627
0
        if (ex_current_was_last) {
628
0
          list->last = prev;
629
0
        }
630
0
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
1.76k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
1.76k
      extracted_link = current;
634
1.76k
      extracted_link->next = nullptr; // for safety
635
1.76k
      current = nullptr;
636
1.76k
      return extracted_link;
637
1.76k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::extract()
Line
Count
Source
607
234k
    T *extract() {
608
234k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
234k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
65.1k
        prev = next = list->last = nullptr;
623
169k
      } else {
624
169k
        prev->next = next; // remove from list
625
626
169k
        ex_current_was_last = (current == list->last);
627
169k
        if (ex_current_was_last) {
628
0
          list->last = prev;
629
0
        }
630
169k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
234k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
234k
      extracted_link = current;
634
234k
      extracted_link->next = nullptr; // for safety
635
234k
      current = nullptr;
636
234k
      return extracted_link;
637
234k
    }  // remove from list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::extract()
Line
Count
Source
607
901k
    T *extract() {
608
901k
      T *extracted_link;
609
610
#ifndef NDEBUG
611
      if (!list) {
612
        NO_LIST.error("ELIST_ITERATOR::extract", ABORT);
613
      }
614
      if (!current) { // list empty or
615
        // element extracted
616
        NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT);
617
      }
618
#endif
619
620
901k
      if (list->singleton()) {
621
        // Special case where we do need to change the iterator.
622
0
        prev = next = list->last = nullptr;
623
901k
      } else {
624
901k
        prev->next = next; // remove from list
625
626
901k
        ex_current_was_last = (current == list->last);
627
901k
        if (ex_current_was_last) {
628
393k
          list->last = prev;
629
393k
        }
630
901k
      }
631
      // Always set ex_current_was_cycle_pt so an add/forward will work in a loop.
632
901k
      ex_current_was_cycle_pt = (current == cycle_pt);
633
901k
      extracted_link = current;
634
901k
      extracted_link->next = nullptr; // for safety
635
901k
      current = nullptr;
636
901k
      return extracted_link;
637
901k
    }  // remove from list
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::extract()
638
      /***********************************************************************
639
     *                          ELIST_ITERATOR::move_to_first()
640
     *
641
     *  Move current so that it is set to the start of the list.
642
     *  Return data just in case anyone wants it.
643
     **********************************************************************/
644
3.37M
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
3.37M
      current = list->First();
652
3.37M
      prev = list->last;
653
3.37M
      next = current ? current->next : nullptr;
654
3.37M
      return current;
655
3.37M
    } // 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
644
359k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
359k
      current = list->First();
652
359k
      prev = list->last;
653
359k
      next = current ? current->next : nullptr;
654
359k
      return current;
655
359k
    } // 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
644
357k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
357k
      current = list->First();
652
357k
      prev = list->last;
653
357k
      next = current ? current->next : nullptr;
654
357k
      return current;
655
357k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::move_to_first()
Line
Count
Source
644
12.8k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
12.8k
      current = list->First();
652
12.8k
      prev = list->last;
653
12.8k
      next = current ? current->next : nullptr;
654
12.8k
      return current;
655
12.8k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::move_to_first()
Line
Count
Source
644
305k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
305k
      current = list->First();
652
305k
      prev = list->last;
653
305k
      next = current ? current->next : nullptr;
654
305k
      return current;
655
305k
    } // 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
644
100k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
100k
      current = list->First();
652
100k
      prev = list->last;
653
100k
      next = current ? current->next : nullptr;
654
100k
      return current;
655
100k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::move_to_first()
Line
Count
Source
644
117k
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
117k
      current = list->First();
652
117k
      prev = list->last;
653
117k
      next = current ? current->next : nullptr;
654
117k
      return current;
655
117k
    } // go to start of list
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::move_to_first()
Line
Count
Source
644
2.12M
    T *move_to_first() {
645
#ifndef NDEBUG
646
      if (!list) {
647
        NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT);
648
      }
649
#endif
650
651
2.12M
      current = list->First();
652
2.12M
      prev = list->last;
653
2.12M
      next = current ? current->next : nullptr;
654
2.12M
      return current;
655
2.12M
    } // go to start of list
656
      /***********************************************************************
657
     *              ELIST_ITERATOR::move_to_last()
658
     *
659
     *  Move current so that it is set to the end of the list.
660
     *  Return data just in case anyone wants it.
661
     *  (This function can't be INLINEd because it contains a loop)
662
     **********************************************************************/
663
5.91M
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
213M
      while (current != list->last) {
670
207M
        forward();
671
207M
      }
672
673
5.91M
      return current;
674
5.91M
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::move_to_last()
Line
Count
Source
663
20.8k
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
49.2k
      while (current != list->last) {
670
28.3k
        forward();
671
28.3k
      }
672
673
20.8k
      return current;
674
20.8k
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::move_to_last()
Line
Count
Source
663
48.6k
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
424k
      while (current != list->last) {
670
375k
        forward();
671
375k
      }
672
673
48.6k
      return current;
674
48.6k
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::move_to_last()
Line
Count
Source
663
67.3k
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
175k
      while (current != list->last) {
670
107k
        forward();
671
107k
      }
672
673
67.3k
      return current;
674
67.3k
    } // 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
663
1.19M
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
29.5M
      while (current != list->last) {
670
28.4M
        forward();
671
28.4M
      }
672
673
1.19M
      return current;
674
1.19M
    } // 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
663
4.51M
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
182M
      while (current != list->last) {
670
178M
        forward();
671
178M
      }
672
673
4.51M
      return current;
674
4.51M
    } // go to end of list
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::move_to_last()
Line
Count
Source
663
66.8k
    T *move_to_last() {
664
#ifndef NDEBUG
665
      if (!list)
666
        NO_LIST.error("ELIST_ITERATOR::move_to_last", ABORT);
667
#endif
668
669
884k
      while (current != list->last) {
670
817k
        forward();
671
817k
      }
672
673
66.8k
      return current;
674
66.8k
    } // go to end of list
675
      /***********************************************************************
676
     *                          ELIST_ITERATOR::mark_cycle_pt()
677
     *
678
     *  Remember the current location so that we can tell whether we've returned
679
     *  to this point later.
680
     *
681
     *  If the current point is deleted either now, or in the future, the cycle
682
     *  point will be set to the next item which is set to current.  This could be
683
     *  by a forward, add_after_then_move or add_after_then_move.
684
     **********************************************************************/
685
447M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
447M
      if (current) {
693
430M
        cycle_pt = current;
694
430M
      } else {
695
17.1M
        ex_current_was_cycle_pt = true;
696
17.1M
      }
697
447M
      started_cycling = false;
698
447M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::mark_cycle_pt()
Line
Count
Source
685
97.2k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
97.2k
      if (current) {
693
91.9k
        cycle_pt = current;
694
91.9k
      } else {
695
5.30k
        ex_current_was_cycle_pt = true;
696
5.30k
      }
697
97.2k
      started_cycling = false;
698
97.2k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::mark_cycle_pt()
Line
Count
Source
685
203M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
203M
      if (current) {
693
190M
        cycle_pt = current;
694
190M
      } else {
695
13.2M
        ex_current_was_cycle_pt = true;
696
13.2M
      }
697
203M
      started_cycling = false;
698
203M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::mark_cycle_pt()
Line
Count
Source
685
3.85M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
3.85M
      if (current) {
693
3.73M
        cycle_pt = current;
694
3.73M
      } else {
695
122k
        ex_current_was_cycle_pt = true;
696
122k
      }
697
3.85M
      started_cycling = false;
698
3.85M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::mark_cycle_pt()
Line
Count
Source
685
57.4k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
57.4k
      if (current) {
693
56.9k
        cycle_pt = current;
694
56.9k
      } else {
695
501
        ex_current_was_cycle_pt = true;
696
501
      }
697
57.4k
      started_cycling = false;
698
57.4k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::mark_cycle_pt()
Line
Count
Source
685
11.3M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
11.3M
      if (current) {
693
7.64M
        cycle_pt = current;
694
7.64M
      } else {
695
3.72M
        ex_current_was_cycle_pt = true;
696
3.72M
      }
697
11.3M
      started_cycling = false;
698
11.3M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::mark_cycle_pt()
Line
Count
Source
685
25.5M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
25.5M
      if (current) {
693
25.5M
        cycle_pt = current;
694
25.5M
      } else {
695
62.2k
        ex_current_was_cycle_pt = true;
696
62.2k
      }
697
25.5M
      started_cycling = false;
698
25.5M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::mark_cycle_pt()
Line
Count
Source
685
8.03M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
8.03M
      if (current) {
693
8.03M
        cycle_pt = current;
694
8.03M
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
8.03M
      started_cycling = false;
698
8.03M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::mark_cycle_pt()
Line
Count
Source
685
1.82M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
1.82M
      if (current) {
693
1.80M
        cycle_pt = current;
694
1.80M
      } else {
695
19.9k
        ex_current_was_cycle_pt = true;
696
19.9k
      }
697
1.82M
      started_cycling = false;
698
1.82M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::mark_cycle_pt()
Line
Count
Source
685
1.38M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
1.38M
      if (current) {
693
1.38M
        cycle_pt = current;
694
1.38M
      } else {
695
9.17k
        ex_current_was_cycle_pt = true;
696
9.17k
      }
697
1.38M
      started_cycling = false;
698
1.38M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
685
6.46M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
6.46M
      if (current) {
693
6.45M
        cycle_pt = current;
694
6.45M
      } else {
695
3.53k
        ex_current_was_cycle_pt = true;
696
3.53k
      }
697
6.46M
      started_cycling = false;
698
6.46M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
685
6.72M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
6.72M
      if (current) {
693
6.72M
        cycle_pt = current;
694
6.72M
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
6.72M
      started_cycling = false;
698
6.72M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::mark_cycle_pt()
Line
Count
Source
685
77.7M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
77.7M
      if (current) {
693
77.7M
        cycle_pt = current;
694
77.7M
      } else {
695
340
        ex_current_was_cycle_pt = true;
696
340
      }
697
77.7M
      started_cycling = false;
698
77.7M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::mark_cycle_pt()
Line
Count
Source
685
362k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
362k
      if (current) {
693
362k
        cycle_pt = current;
694
362k
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
362k
      started_cycling = false;
698
362k
    } // 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
685
99.0M
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
99.0M
      if (current) {
693
99.0M
        cycle_pt = current;
694
99.0M
      } else {
695
1.62k
        ex_current_was_cycle_pt = true;
696
1.62k
      }
697
99.0M
      started_cycling = false;
698
99.0M
    } // remember current
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::mark_cycle_pt()
Line
Count
Source
685
169k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
169k
      if (current) {
693
169k
        cycle_pt = current;
694
169k
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
169k
      started_cycling = false;
698
169k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::mark_cycle_pt()
Line
Count
Source
685
901k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
901k
      if (current) {
693
901k
        cycle_pt = current;
694
901k
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
901k
      started_cycling = false;
698
901k
    } // remember current
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::mark_cycle_pt()
Line
Count
Source
685
66.8k
    void mark_cycle_pt() {
686
#ifndef NDEBUG
687
      if (!list) {
688
        NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT);
689
      }
690
#endif
691
692
66.8k
      if (current) {
693
66.8k
        cycle_pt = current;
694
66.8k
      } else {
695
0
        ex_current_was_cycle_pt = true;
696
0
      }
697
66.8k
      started_cycling = false;
698
66.8k
    } // remember current
699
700
36.1M
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
36.1M
      return list->empty();
707
36.1M
    }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::empty() const
Line
Count
Source
700
24.4M
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
24.4M
      return list->empty();
707
24.4M
    }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::empty() const
Line
Count
Source
700
1.75M
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
1.75M
      return list->empty();
707
1.75M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::empty() const
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::empty() const
Line
Count
Source
700
2.09M
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
2.09M
      return list->empty();
707
2.09M
    }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::empty() const
Line
Count
Source
700
933k
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
933k
      return list->empty();
707
933k
    }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::empty() const
Line
Count
Source
700
6.45M
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
6.45M
      return list->empty();
707
6.45M
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::empty() const
Line
Count
Source
700
288k
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
288k
      return list->empty();
707
288k
    }
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
700
182k
    bool empty() const { // is list empty?
701
#ifndef NDEBUG
702
      if (!list) {
703
        NO_LIST.error("ELIST_ITERATOR::empty", ABORT);
704
      }
705
#endif
706
182k
      return list->empty();
707
182k
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::empty() const
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::empty() const
708
709
    bool current_extracted() const { // current extracted?
710
      return !current;
711
    }
712
    /***********************************************************************
713
   *                          ELIST_ITERATOR::at_first()
714
   *
715
   *  Are we at the start of the list?
716
   *
717
   **********************************************************************/
718
91.4M
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
91.4M
      return ((list->empty()) || (current == list->First()) ||
727
69.3M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
15.7M
          !ex_current_was_last));                         // first and last
729
91.4M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::at_first() const
Line
Count
Source
718
732k
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
732k
      return ((list->empty()) || (current == list->First()) ||
727
579k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
473k
          !ex_current_was_last));                         // first and last
729
732k
    } // 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
718
510k
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
510k
      return ((list->empty()) || (current == list->First()) ||
727
396k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
187k
          !ex_current_was_last));                         // first and last
729
510k
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::at_first() const
Line
Count
Source
718
4.64M
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
4.64M
      return ((list->empty()) || (current == list->First()) ||
727
3.89M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
0
          !ex_current_was_last));                         // first and last
729
4.64M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::at_first() const
Line
Count
Source
718
33.7M
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
33.7M
      return ((list->empty()) || (current == list->First()) ||
727
28.3M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
7.45M
          !ex_current_was_last));                         // first and last
729
33.7M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::at_first() const
Line
Count
Source
718
19.7M
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
19.7M
      return ((list->empty()) || (current == list->First()) ||
727
11.8M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
79.6k
          !ex_current_was_last));                         // first and last
729
19.7M
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::at_first() const
Line
Count
Source
718
706k
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
706k
      return ((list->empty()) || (current == list->First()) ||
727
629k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
591k
          !ex_current_was_last));                         // first and last
729
706k
    } // 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
718
126k
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
126k
      return ((list->empty()) || (current == list->First()) ||
727
126k
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
126k
          !ex_current_was_last));                         // first and last
729
126k
    } // Current is first?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::at_first() const
Line
Count
Source
718
31.2M
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
31.2M
      return ((list->empty()) || (current == list->First()) ||
727
23.5M
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
6.83M
          !ex_current_was_last));                         // first and last
729
31.2M
    } // 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
718
34.8k
    bool at_first() const {
719
#ifndef NDEBUG
720
      if (!list) {
721
        NO_LIST.error("ELIST_ITERATOR::at_first", ABORT);
722
      }
723
#endif
724
725
      // we're at a deleted
726
34.8k
      return ((list->empty()) || (current == list->First()) ||
727
0
        ((current == nullptr) && (prev == list->last) && // NON-last pt between
728
0
          !ex_current_was_last));                         // first and last
729
34.8k
    } // Current is first?
730
      /***********************************************************************
731
     *                          ELIST_ITERATOR::at_last()
732
     *
733
     *  Are we at the end of the list?
734
     *
735
     **********************************************************************/
736
51.5M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
51.5M
      return ((list->empty()) || (current == list->last) ||
745
30.3M
        ((current == nullptr) && (prev == list->last) && // last point between
746
15.7M
          ex_current_was_last));                          // first and last
747
51.5M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::at_last() const
Line
Count
Source
736
594k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
594k
      return ((list->empty()) || (current == list->last) ||
745
473k
        ((current == nullptr) && (prev == list->last) && // last point between
746
473k
          ex_current_was_last));                          // first and last
747
594k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::at_last() const
Line
Count
Source
736
16.2k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
16.2k
      return ((list->empty()) || (current == list->last) ||
745
0
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
16.2k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::at_last() const
Line
Count
Source
736
328k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
328k
      return ((list->empty()) || (current == list->last) ||
745
187k
        ((current == nullptr) && (prev == list->last) && // last point between
746
187k
          ex_current_was_last));                          // first and last
747
328k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::at_last() const
Line
Count
Source
736
14.8M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
14.8M
      return ((list->empty()) || (current == list->last) ||
745
13.6M
        ((current == nullptr) && (prev == list->last) && // last point between
746
7.45M
          ex_current_was_last));                          // first and last
747
14.8M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::at_last() const
Line
Count
Source
736
9.69M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
9.69M
      return ((list->empty()) || (current == list->last) ||
745
2.20M
        ((current == nullptr) && (prev == list->last) && // last point between
746
79.7k
          ex_current_was_last));                          // first and last
747
9.69M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::at_last() const
Line
Count
Source
736
1.22M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
1.22M
      return ((list->empty()) || (current == list->last) ||
745
656k
        ((current == nullptr) && (prev == list->last) && // last point between
746
591k
          ex_current_was_last));                          // first and last
747
1.22M
    } // 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
736
14.4k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
14.4k
      return ((list->empty()) || (current == list->last) ||
745
0
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
14.4k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::at_last() const
Line
Count
Source
736
140k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
140k
      return ((list->empty()) || (current == list->last) ||
745
126k
        ((current == nullptr) && (prev == list->last) && // last point between
746
126k
          ex_current_was_last));                          // first and last
747
140k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::at_last() const
Line
Count
Source
736
345k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
345k
      return ((list->empty()) || (current == list->last) ||
745
25.6k
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
345k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::at_last() const
Line
Count
Source
736
20.2M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
20.2M
      return ((list->empty()) || (current == list->last) ||
745
9.53M
        ((current == nullptr) && (prev == list->last) && // last point between
746
6.83M
          ex_current_was_last));                          // first and last
747
20.2M
    } // 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
736
139k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
139k
      return ((list->empty()) || (current == list->last) ||
745
34.8k
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
139k
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::at_last() const
Line
Count
Source
736
3.07M
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
3.07M
      return ((list->empty()) || (current == list->last) ||
745
2.61M
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
3.07M
    } // Current is last?
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::at_last() const
Line
Count
Source
736
884k
    bool at_last() const {
737
#ifndef NDEBUG
738
      if (!list) {
739
        NO_LIST.error("ELIST_ITERATOR::at_last", ABORT);
740
      }
741
#endif
742
743
      // we're at a deleted
744
884k
      return ((list->empty()) || (current == list->last) ||
745
817k
        ((current == nullptr) && (prev == list->last) && // last point between
746
0
          ex_current_was_last));                          // first and last
747
884k
    } // Current is last?
748
      /***********************************************************************
749
     *                          ELIST_ITERATOR::cycled_list()
750
     *
751
     *  Have we returned to the cycle_pt since it was set?
752
     *
753
     **********************************************************************/
754
2.98G
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
2.98G
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
2.98G
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::cycled_list() const
Line
Count
Source
754
189k
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
189k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
189k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::cycled_list() const
Line
Count
Source
754
478M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
478M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
478M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::cycled_list() const
Line
Count
Source
754
4.14M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
4.14M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
4.14M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::cycled_list() const
Line
Count
Source
754
59.1M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
59.1M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
59.1M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ROW>::Iterator::cycled_list() const
Line
Count
Source
754
656k
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
656k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
656k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::cycled_list() const
Line
Count
Source
754
163M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
163M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
163M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::cycled_list() const
Line
Count
Source
754
107M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
107M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
107M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::Iterator::cycled_list() const
Line
Count
Source
754
562M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
562M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
562M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::cycled_list() const
Line
Count
Source
754
11.6M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
11.6M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
11.6M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::Iterator::cycled_list() const
Line
Count
Source
754
116M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
116M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
116M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::cycled_list() const
Line
Count
Source
754
188M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
188M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
188M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::cycled_list() const
Line
Count
Source
754
461M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
461M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
461M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::Iterator::cycled_list() const
Line
Count
Source
754
725k
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
725k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
725k
    } // 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
754
829M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
829M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
829M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::Iterator::cycled_list() const
Line
Count
Source
754
513k
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
513k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
513k
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::Iterator::cycled_list() const
Line
Count
Source
754
3.63M
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
3.63M
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
3.63M
    } // Completed a cycle?
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::Iterator::cycled_list() const
Line
Count
Source
754
951k
    bool cycled_list() const {
755
#ifndef NDEBUG
756
      if (!list) {
757
        NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT);
758
      }
759
#endif
760
761
951k
      return ((list->empty()) || ((current == cycle_pt) && started_cycling));
762
951k
    } // Completed a cycle?
763
      /***********************************************************************
764
     *                          ELIST_ITERATOR::add_to_end
765
     *
766
     *  Add a new element to the end of the list without moving the iterator.
767
     *  This is provided because a single linked list cannot move to the last as
768
     *  the iterator couldn't set its prev pointer.  Adding to the end is
769
     *  essential for implementing
770
                  queues.
771
    **********************************************************************/
772
    void add_to_end(           // add at end &
773
44.8M
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
44.8M
      if (this->at_last()) {
787
20.5M
        this->add_after_stay_put(new_element);
788
24.2M
      } else {
789
24.2M
        if (this->at_first()) {
790
24.2M
          this->add_before_stay_put(new_element);
791
24.2M
          list->last = new_element;
792
24.2M
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
24.2M
      }
798
44.8M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::Iterator::add_to_end(tesseract::C_BLOB*)
Line
Count
Source
773
594k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
594k
      if (this->at_last()) {
787
120k
        this->add_after_stay_put(new_element);
788
473k
      } else {
789
473k
        if (this->at_first()) {
790
473k
          this->add_before_stay_put(new_element);
791
473k
          list->last = new_element;
792
473k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
473k
      }
798
594k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOCK>::Iterator::add_to_end(tesseract::BLOCK*)
Line
Count
Source
773
16.2k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
16.2k
      if (this->at_last()) {
787
16.2k
        this->add_after_stay_put(new_element);
788
16.2k
      } else {
789
0
        if (this->at_first()) {
790
0
          this->add_before_stay_put(new_element);
791
0
          list->last = new_element;
792
0
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
0
      }
798
16.2k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::Iterator::add_to_end(tesseract::WERD_RES*)
Line
Count
Source
773
328k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
328k
      if (this->at_last()) {
787
140k
        this->add_after_stay_put(new_element);
788
187k
      } else {
789
187k
        if (this->at_first()) {
790
187k
          this->add_before_stay_put(new_element);
791
187k
          list->last = new_element;
792
187k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
187k
      }
798
328k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::add_to_end(tesseract::BLOBNBOX*)
Line
Count
Source
773
12.1M
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
12.1M
      if (this->at_last()) {
787
1.06M
        this->add_after_stay_put(new_element);
788
11.0M
      } else {
789
11.0M
        if (this->at_first()) {
790
11.0M
          this->add_before_stay_put(new_element);
791
11.0M
          list->last = new_element;
792
11.0M
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
11.0M
      }
798
12.1M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::Iterator::add_to_end(tesseract::C_OUTLINE*)
Line
Count
Source
773
9.69M
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
9.69M
      if (this->at_last()) {
787
7.49M
        this->add_after_stay_put(new_element);
788
7.49M
      } else {
789
2.19M
        if (this->at_first()) {
790
2.19M
          this->add_before_stay_put(new_element);
791
2.19M
          list->last = new_element;
792
2.19M
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
2.19M
      }
798
9.69M
    } // don't move
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::add_to_end(tesseract::ICOORDELT*)
Line
Count
Source
773
1.22M
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
1.22M
      if (this->at_last()) {
787
567k
        this->add_after_stay_put(new_element);
788
656k
      } else {
789
656k
        if (this->at_first()) {
790
656k
          this->add_before_stay_put(new_element);
791
656k
          list->last = new_element;
792
656k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
656k
      }
798
1.22M
    } // 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
773
14.4k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
14.4k
      if (this->at_last()) {
787
14.4k
        this->add_after_stay_put(new_element);
788
14.4k
      } else {
789
0
        if (this->at_first()) {
790
0
          this->add_before_stay_put(new_element);
791
0
          list->last = new_element;
792
0
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
0
      }
798
14.4k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::Iterator::add_to_end(tesseract::ROW_RES*)
Line
Count
Source
773
140k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
140k
      if (this->at_last()) {
787
14.4k
        this->add_after_stay_put(new_element);
788
126k
      } else {
789
126k
        if (this->at_first()) {
790
126k
          this->add_before_stay_put(new_element);
791
126k
          list->last = new_element;
792
126k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
126k
      }
798
140k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::Iterator::add_to_end(tesseract::WERD_CHOICE*)
Line
Count
Source
773
345k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
345k
      if (this->at_last()) {
787
320k
        this->add_after_stay_put(new_element);
788
320k
      } else {
789
25.6k
        if (this->at_first()) {
790
25.6k
          this->add_before_stay_put(new_element);
791
25.6k
          list->last = new_element;
792
25.6k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
25.6k
      }
798
345k
    } // don't move
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::add_to_end(tesseract::BLOB_CHOICE*)
Line
Count
Source
773
20.2M
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
20.2M
      if (this->at_last()) {
787
10.6M
        this->add_after_stay_put(new_element);
788
10.6M
      } else {
789
9.53M
        if (this->at_first()) {
790
9.53M
          this->add_before_stay_put(new_element);
791
9.53M
          list->last = new_element;
792
9.53M
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
9.53M
      }
798
20.2M
    } // 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
773
139k
      T *new_element) {
774
#ifndef NDEBUG
775
      if (!list) {
776
        NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT);
777
      }
778
      if (!new_element) {
779
        BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
780
      }
781
      if (new_element->next) {
782
        STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT);
783
      }
784
#endif
785
786
139k
      if (this->at_last()) {
787
104k
        this->add_after_stay_put(new_element);
788
104k
      } else {
789
34.8k
        if (this->at_first()) {
790
34.8k
          this->add_before_stay_put(new_element);
791
34.8k
          list->last = new_element;
792
34.8k
        } else { // Iteratr is elsewhere
793
0
          new_element->next = list->last->next;
794
0
          list->last->next = new_element;
795
0
          list->last = new_element;
796
0
        }
797
34.8k
      }
798
139k
    } // don't move
799
        /***********************************************************************
800
     *              ELIST_ITERATOR::exchange()
801
     *
802
     *  Given another iterator, whose current element is a different element on
803
     *  the same list list OR an element of another list, exchange the two current
804
     *  elements.  On return, each iterator points to the element which was the
805
     *  other iterators current on entry.
806
     *  (This function hasn't been in-lined because its a bit big!)
807
     **********************************************************************/
808
    void exchange(                 // positions of 2 links
809
      Iterator *other_it) { // other iterator
810
      constexpr ERRCODE DONT_EXCHANGE_DELETED("Can't exchange deleted elements of lists");
811
812
      T *old_current;
813
814
#ifndef NDEBUG
815
      if (!list)
816
        NO_LIST.error("ELIST_ITERATOR::exchange", ABORT);
817
      if (!other_it)
818
        BAD_PARAMETER.error("ELIST_ITERATOR::exchange", ABORT, "other_it nullptr");
819
      if (!(other_it->list))
820
        NO_LIST.error("ELIST_ITERATOR::exchange", ABORT, "other_it");
821
#endif
822
823
      /* Do nothing if either list is empty or if both iterators reference the same
824
    link */
825
826
      if ((list->empty()) || (other_it->list->empty()) || (current == other_it->current)) {
827
        return;
828
      }
829
830
      /* Error if either current element is deleted */
831
832
      if (!current || !other_it->current) {
833
        DONT_EXCHANGE_DELETED.error("ELIST_ITERATOR.exchange", ABORT);
834
      }
835
836
      /* Now handle the 4 cases: doubleton list; non-doubleton adjacent elements
837
    (other before this); non-doubleton adjacent elements (this before other);
838
    non-adjacent elements. */
839
840
    // adjacent links
841
      if ((next == other_it->current) || (other_it->next == current)) {
842
        // doubleton list
843
        if ((next == other_it->current) && (other_it->next == current)) {
844
          prev = next = current;
845
          other_it->prev = other_it->next = other_it->current;
846
        } else { // non-doubleton with
847
          // adjacent links
848
          // other before this
849
          if (other_it->next == current) {
850
            other_it->prev->next = current;
851
            other_it->current->next = next;
852
            current->next = other_it->current;
853
            other_it->next = other_it->current;
854
            prev = current;
855
          } else { // this before other
856
            prev->next = other_it->current;
857
            current->next = other_it->next;
858
            other_it->current->next = current;
859
            next = current;
860
            other_it->prev = other_it->current;
861
          }
862
        }
863
      } else { // no overlap
864
        prev->next = other_it->current;
865
        current->next = other_it->next;
866
        other_it->prev->next = current;
867
        other_it->current->next = next;
868
      }
869
870
      /* update end of list pointer when necessary (remember that the 2 iterators
871
      may iterate over different lists!) */
872
873
      if (list->last == current) {
874
        list->last = other_it->current;
875
      }
876
      if (other_it->list->last == other_it->current) {
877
        other_it->list->last = current;
878
      }
879
880
      if (current == cycle_pt) {
881
        cycle_pt = other_it->cycle_pt;
882
      }
883
      if (other_it->current == other_it->cycle_pt) {
884
        other_it->cycle_pt = cycle_pt;
885
      }
886
887
      /* The actual exchange - in all cases*/
888
889
      old_current = current;
890
      current = other_it->current;
891
      other_it->current = old_current;
892
    } // other iterator
893
894
      //# elements in list
895
8.79M
    int32_t length() const {
896
8.79M
      return list->length();
897
8.79M
    }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::length() const
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::Iterator::length() const
Line
Count
Source
895
8.79M
    int32_t length() const {
896
8.79M
      return list->length();
897
8.79M
    }
898
    /***********************************************************************
899
   *                          ELIST_ITERATOR::sort()
900
   *
901
   *  Sort the elements of the list, then reposition at the start.
902
   *
903
   **********************************************************************/
904
    void sort(          // sort elements
905
      int comparator( // comparison routine
906
573k
        const T *, const T *)) {
907
#ifndef NDEBUG
908
      if (!list) {
909
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
910
      }
911
#endif
912
913
573k
      list->sort(comparator);
914
573k
      move_to_first();
915
573k
    }
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
906
229k
        const T *, const T *)) {
907
#ifndef NDEBUG
908
      if (!list) {
909
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
910
      }
911
#endif
912
913
229k
      list->sort(comparator);
914
229k
      move_to_first();
915
229k
    }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::Iterator::sort(int (*)(tesseract::ICOORDELT const*, tesseract::ICOORDELT const*))
Line
Count
Source
906
261k
        const T *, const T *)) {
907
#ifndef NDEBUG
908
      if (!list) {
909
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
910
      }
911
#endif
912
913
261k
      list->sort(comparator);
914
261k
      move_to_first();
915
261k
    }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::Iterator::sort(int (*)(tesseract::BLOBNBOX const*, tesseract::BLOBNBOX const*))
Line
Count
Source
906
83.1k
        const T *, const T *)) {
907
#ifndef NDEBUG
908
      if (!list) {
909
        NO_LIST.error("ELIST_ITERATOR::sort", ABORT);
910
      }
911
#endif
912
913
83.1k
      list->sort(comparator);
914
83.1k
      move_to_first();
915
83.1k
    }
916
  };
917
  using ITERATOR = Iterator; // compat
918
919
private:
920
  T *last = nullptr; // End of list
921
  //(Points to head)
922
607M
  T *First() { // return first
923
607M
    return last ? last->next : nullptr;
924
607M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::First()
Line
Count
Source
922
113k
  T *First() { // return first
923
113k
    return last ? last->next : nullptr;
924
113k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::First()
Line
Count
Source
922
255M
  T *First() { // return first
923
255M
    return last ? last->next : nullptr;
924
255M
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::First()
Line
Count
Source
922
48.9M
  T *First() { // return first
923
48.9M
    return last ? last->next : nullptr;
924
48.9M
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::First()
Line
Count
Source
922
86.0k
  T *First() { // return first
923
86.0k
    return last ? last->next : nullptr;
924
86.0k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::First()
Line
Count
Source
922
15.3M
  T *First() { // return first
923
15.3M
    return last ? last->next : nullptr;
924
15.3M
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::First()
Line
Count
Source
922
74.2M
  T *First() { // return first
923
74.2M
    return last ? last->next : nullptr;
924
74.2M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::First()
Line
Count
Source
922
8.03M
  T *First() { // return first
923
8.03M
    return last ? last->next : nullptr;
924
8.03M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::First()
Line
Count
Source
922
8.11M
  T *First() { // return first
923
8.11M
    return last ? last->next : nullptr;
924
8.11M
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::First()
Line
Count
Source
922
2.52M
  T *First() { // return first
923
2.52M
    return last ? last->next : nullptr;
924
2.52M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::First()
Line
Count
Source
922
372k
  T *First() { // return first
923
372k
    return last ? last->next : nullptr;
924
372k
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::First()
Line
Count
Source
922
14.4k
  T *First() { // return first
923
14.4k
    return last ? last->next : nullptr;
924
14.4k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::First()
Line
Count
Source
922
6.47M
  T *First() { // return first
923
6.47M
    return last ? last->next : nullptr;
924
6.47M
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::First()
Line
Count
Source
922
6.86M
  T *First() { // return first
923
6.86M
    return last ? last->next : nullptr;
924
6.86M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::First()
Line
Count
Source
922
78.3M
  T *First() { // return first
923
78.3M
    return last ? last->next : nullptr;
924
78.3M
  }
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
922
99.0M
  T *First() { // return first
923
99.0M
    return last ? last->next : nullptr;
924
99.0M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::First()
Line
Count
Source
922
451k
  T *First() { // return first
923
451k
    return last ? last->next : nullptr;
924
451k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::First()
Line
Count
Source
922
2.29M
  T *First() { // return first
923
2.29M
    return last ? last->next : nullptr;
924
2.29M
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::First()
Line
Count
Source
922
200k
  T *First() { // return first
923
200k
    return last ? last->next : nullptr;
924
200k
  }
925
926
public:
927
31.2M
  ~IntrusiveForwardList() {
928
31.2M
    clear();
929
31.2M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::~IntrusiveForwardList()
Line
Count
Source
927
16.2k
  ~IntrusiveForwardList() {
928
16.2k
    clear();
929
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::~IntrusiveForwardList()
Line
Count
Source
927
14.4k
  ~IntrusiveForwardList() {
928
14.4k
    clear();
929
14.4k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::~IntrusiveForwardList()
Line
Count
Source
927
140k
  ~IntrusiveForwardList() {
928
140k
    clear();
929
140k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::BLOCK>::~IntrusiveForwardList()
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::~IntrusiveForwardList()
Line
Count
Source
927
1.59M
  ~IntrusiveForwardList() {
928
1.59M
    clear();
929
1.59M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::~IntrusiveForwardList()
Line
Count
Source
927
16.9M
  ~IntrusiveForwardList() {
928
16.9M
    clear();
929
16.9M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::~IntrusiveForwardList()
Line
Count
Source
927
16.2k
  ~IntrusiveForwardList() {
928
16.2k
    clear();
929
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::~IntrusiveForwardList()
Line
Count
Source
927
16.2k
  ~IntrusiveForwardList() {
928
16.2k
    clear();
929
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::~IntrusiveForwardList()
Line
Count
Source
927
634k
  ~IntrusiveForwardList() {
928
634k
    clear();
929
634k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::~IntrusiveForwardList()
Line
Count
Source
927
9.27M
  ~IntrusiveForwardList() {
928
9.27M
    clear();
929
9.27M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::~IntrusiveForwardList()
Line
Count
Source
927
739k
  ~IntrusiveForwardList() {
928
739k
    clear();
929
739k
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::~IntrusiveForwardList()
Line
Count
Source
927
16.2k
  ~IntrusiveForwardList() {
928
16.2k
    clear();
929
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::~IntrusiveForwardList()
Line
Count
Source
927
391k
  ~IntrusiveForwardList() {
928
391k
    clear();
929
391k
  }
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
927
785k
  ~IntrusiveForwardList() {
928
785k
    clear();
929
785k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::~IntrusiveForwardList()
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::~IntrusiveForwardList()
Line
Count
Source
927
329k
  ~IntrusiveForwardList() {
928
329k
    clear();
929
329k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::~IntrusiveForwardList()
Line
Count
Source
927
178k
  ~IntrusiveForwardList() {
928
178k
    clear();
929
178k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::~IntrusiveForwardList()
Line
Count
Source
927
133k
  ~IntrusiveForwardList() {
928
133k
    clear();
929
133k
  }
930
931
  /* delete elements */
932
33.8M
  void clear() {
933
33.8M
    internal_clear();
934
33.8M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::clear()
Line
Count
Source
932
16.2k
  void clear() {
933
16.2k
    internal_clear();
934
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::clear()
Line
Count
Source
932
14.4k
  void clear() {
933
14.4k
    internal_clear();
934
14.4k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::clear()
Line
Count
Source
932
140k
  void clear() {
933
140k
    internal_clear();
934
140k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::clear()
Line
Count
Source
932
16.2k
  void clear() {
933
16.2k
    internal_clear();
934
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::clear()
Line
Count
Source
932
1.96M
  void clear() {
933
1.96M
    internal_clear();
934
1.96M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::clear()
Line
Count
Source
932
16.9M
  void clear() {
933
16.9M
    internal_clear();
934
16.9M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::clear()
Line
Count
Source
932
45.0k
  void clear() {
933
45.0k
    internal_clear();
934
45.0k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::clear()
Line
Count
Source
932
16.2k
  void clear() {
933
16.2k
    internal_clear();
934
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::clear()
Line
Count
Source
932
868k
  void clear() {
933
868k
    internal_clear();
934
868k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::clear()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::clear()
Line
Count
Source
932
391k
  void clear() {
933
391k
    internal_clear();
934
391k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::clear()
Line
Count
Source
932
2.57M
  void clear() {
933
2.57M
    internal_clear();
934
2.57M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::clear()
Line
Count
Source
932
785k
  void clear() {
933
785k
    internal_clear();
934
785k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::clear()
Line
Count
Source
932
9.27M
  void clear() {
933
9.27M
    internal_clear();
934
9.27M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::clear()
Line
Count
Source
932
16.2k
  void clear() {
933
16.2k
    internal_clear();
934
16.2k
  }
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
932
329k
  void clear() {
933
329k
    internal_clear();
934
329k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::clear()
Line
Count
Source
932
178k
  void clear() {
933
178k
    internal_clear();
934
178k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::clear()
Line
Count
Source
932
200k
  void clear() {
933
200k
    internal_clear();
934
200k
  }
935
936
  /* Become a deep copy of src_list */
937
  template <typename U>
938
1.71M
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
939
1.71M
    Iterator from_it(const_cast<U *>(src_list));
940
1.71M
    Iterator to_it(this);
941
942
3.13M
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
943
1.42M
      to_it.add_after_then_move((*copier)(from_it.data()));
944
1.71M
  }
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
938
1.42M
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
939
1.42M
    Iterator from_it(const_cast<U *>(src_list));
940
1.42M
    Iterator to_it(this);
941
942
2.27M
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
943
848k
      to_it.add_after_then_move((*copier)(from_it.data()));
944
1.42M
  }
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
938
293k
  void deep_copy(const U *src_list, T *(*copier)(const T *)) {
939
293k
    Iterator from_it(const_cast<U *>(src_list));
940
293k
    Iterator to_it(this);
941
942
867k
    for (from_it.mark_cycle_pt(); !from_it.cycled_list(); from_it.forward())
943
574k
      to_it.add_after_then_move((*copier)(from_it.data()));
944
293k
  }
945
946
  /***********************************************************************
947
   *              IntrusiveForwardList::internal_clear
948
   *
949
   *  Used by the destructor and the "clear" member function of derived list
950
   *  classes to destroy all the elements on the list.
951
   *  The calling function passes a "zapper" function which can be called to
952
   *  delete each element of the list, regardless of its derived type.  This
953
   *  technique permits a generic clear function to destroy elements of
954
   *  different derived types correctly, without requiring virtual functions and
955
   *  the consequential memory overhead.
956
   **********************************************************************/
957
958
   // destroy all links
959
33.8M
  void internal_clear() {
960
33.8M
    T *ptr;
961
33.8M
    T *next;
962
963
33.8M
    if (!empty()) {
964
14.2M
      ptr = last->next;     // set to first
965
14.2M
      last->next = nullptr; // break circle
966
14.2M
      last = nullptr;       // set list empty
967
53.3M
      while (ptr) {
968
39.1M
        next = ptr->next;
969
39.1M
        delete ptr;
970
39.1M
        ptr = next;
971
39.1M
      }
972
14.2M
    }
973
33.8M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::internal_clear()
Line
Count
Source
959
16.2k
  void internal_clear() {
960
16.2k
    T *ptr;
961
16.2k
    T *next;
962
963
16.2k
    if (!empty()) {
964
14.4k
      ptr = last->next;     // set to first
965
14.4k
      last->next = nullptr; // break circle
966
14.4k
      last = nullptr;       // set list empty
967
28.8k
      while (ptr) {
968
14.4k
        next = ptr->next;
969
14.4k
        delete ptr;
970
14.4k
        ptr = next;
971
14.4k
      }
972
14.4k
    }
973
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::internal_clear()
Line
Count
Source
959
14.4k
  void internal_clear() {
960
14.4k
    T *ptr;
961
14.4k
    T *next;
962
963
14.4k
    if (!empty()) {
964
14.4k
      ptr = last->next;     // set to first
965
14.4k
      last->next = nullptr; // break circle
966
14.4k
      last = nullptr;       // set list empty
967
155k
      while (ptr) {
968
140k
        next = ptr->next;
969
140k
        delete ptr;
970
140k
        ptr = next;
971
140k
      }
972
14.4k
    }
973
14.4k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::internal_clear()
Line
Count
Source
959
140k
  void internal_clear() {
960
140k
    T *ptr;
961
140k
    T *next;
962
963
140k
    if (!empty()) {
964
140k
      ptr = last->next;     // set to first
965
140k
      last->next = nullptr; // break circle
966
140k
      last = nullptr;       // set list empty
967
481k
      while (ptr) {
968
340k
        next = ptr->next;
969
340k
        delete ptr;
970
340k
        ptr = next;
971
340k
      }
972
140k
    }
973
140k
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::internal_clear()
Line
Count
Source
959
16.2k
  void internal_clear() {
960
16.2k
    T *ptr;
961
16.2k
    T *next;
962
963
16.2k
    if (!empty()) {
964
14.4k
      ptr = last->next;     // set to first
965
14.4k
      last->next = nullptr; // break circle
966
14.4k
      last = nullptr;       // set list empty
967
28.8k
      while (ptr) {
968
14.4k
        next = ptr->next;
969
14.4k
        delete ptr;
970
14.4k
        ptr = next;
971
14.4k
      }
972
14.4k
    }
973
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::internal_clear()
Line
Count
Source
959
1.96M
  void internal_clear() {
960
1.96M
    T *ptr;
961
1.96M
    T *next;
962
963
1.96M
    if (!empty()) {
964
564k
      ptr = last->next;     // set to first
965
564k
      last->next = nullptr; // break circle
966
564k
      last = nullptr;       // set list empty
967
2.55M
      while (ptr) {
968
1.99M
        next = ptr->next;
969
1.99M
        delete ptr;
970
1.99M
        ptr = next;
971
1.99M
      }
972
564k
    }
973
1.96M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::internal_clear()
Line
Count
Source
959
16.9M
  void internal_clear() {
960
16.9M
    T *ptr;
961
16.9M
    T *next;
962
963
16.9M
    if (!empty()) {
964
2.47M
      ptr = last->next;     // set to first
965
2.47M
      last->next = nullptr; // break circle
966
2.47M
      last = nullptr;       // set list empty
967
6.28M
      while (ptr) {
968
3.80M
        next = ptr->next;
969
3.80M
        delete ptr;
970
3.80M
        ptr = next;
971
3.80M
      }
972
2.47M
    }
973
16.9M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::internal_clear()
Line
Count
Source
959
45.0k
  void internal_clear() {
960
45.0k
    T *ptr;
961
45.0k
    T *next;
962
963
45.0k
    if (!empty()) {
964
14.4k
      ptr = last->next;     // set to first
965
14.4k
      last->next = nullptr; // break circle
966
14.4k
      last = nullptr;       // set list empty
967
35.4k
      while (ptr) {
968
21.0k
        next = ptr->next;
969
21.0k
        delete ptr;
970
21.0k
        ptr = next;
971
21.0k
      }
972
14.4k
    }
973
45.0k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::internal_clear()
Line
Count
Source
959
16.2k
  void internal_clear() {
960
16.2k
    T *ptr;
961
16.2k
    T *next;
962
963
16.2k
    if (!empty()) {
964
14.4k
      ptr = last->next;     // set to first
965
14.4k
      last->next = nullptr; // break circle
966
14.4k
      last = nullptr;       // set list empty
967
155k
      while (ptr) {
968
140k
        next = ptr->next;
969
140k
        delete ptr;
970
140k
        ptr = next;
971
140k
      }
972
14.4k
    }
973
16.2k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::internal_clear()
Line
Count
Source
959
868k
  void internal_clear() {
960
868k
    T *ptr;
961
868k
    T *next;
962
963
868k
    if (!empty()) {
964
372k
      ptr = last->next;     // set to first
965
372k
      last->next = nullptr; // break circle
966
372k
      last = nullptr;       // set list empty
967
1.69M
      while (ptr) {
968
1.32M
        next = ptr->next;
969
1.32M
        delete ptr;
970
1.32M
        ptr = next;
971
1.32M
      }
972
372k
    }
973
868k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::internal_clear()
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::internal_clear()
Line
Count
Source
959
391k
  void internal_clear() {
960
391k
    T *ptr;
961
391k
    T *next;
962
963
391k
    if (!empty()) {
964
185k
      ptr = last->next;     // set to first
965
185k
      last->next = nullptr; // break circle
966
185k
      last = nullptr;       // set list empty
967
3.14M
      while (ptr) {
968
2.96M
        next = ptr->next;
969
2.96M
        delete ptr;
970
2.96M
        ptr = next;
971
2.96M
      }
972
185k
    }
973
391k
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::internal_clear()
Line
Count
Source
959
2.57M
  void internal_clear() {
960
2.57M
    T *ptr;
961
2.57M
    T *next;
962
963
2.57M
    if (!empty()) {
964
282k
      ptr = last->next;     // set to first
965
282k
      last->next = nullptr; // break circle
966
282k
      last = nullptr;       // set list empty
967
1.20M
      while (ptr) {
968
922k
        next = ptr->next;
969
922k
        delete ptr;
970
922k
        ptr = next;
971
922k
      }
972
282k
    }
973
2.57M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::internal_clear()
Line
Count
Source
959
785k
  void internal_clear() {
960
785k
    T *ptr;
961
785k
    T *next;
962
963
785k
    if (!empty()) {
964
785k
      ptr = last->next;     // set to first
965
785k
      last->next = nullptr; // break circle
966
785k
      last = nullptr;       // set list empty
967
6.56M
      while (ptr) {
968
5.77M
        next = ptr->next;
969
5.77M
        delete ptr;
970
5.77M
        ptr = next;
971
5.77M
      }
972
785k
    }
973
785k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::internal_clear()
Line
Count
Source
959
9.27M
  void internal_clear() {
960
9.27M
    T *ptr;
961
9.27M
    T *next;
962
963
9.27M
    if (!empty()) {
964
9.21M
      ptr = last->next;     // set to first
965
9.21M
      last->next = nullptr; // break circle
966
9.21M
      last = nullptr;       // set list empty
967
29.5M
      while (ptr) {
968
20.3M
        next = ptr->next;
969
20.3M
        delete ptr;
970
20.3M
        ptr = next;
971
20.3M
      }
972
9.21M
    }
973
9.27M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::internal_clear()
Line
Count
Source
959
16.2k
  void internal_clear() {
960
16.2k
    T *ptr;
961
16.2k
    T *next;
962
963
16.2k
    if (!empty()) {
964
16.2k
      ptr = last->next;     // set to first
965
16.2k
      last->next = nullptr; // break circle
966
16.2k
      last = nullptr;       // set list empty
967
32.4k
      while (ptr) {
968
16.2k
        next = ptr->next;
969
16.2k
        delete ptr;
970
16.2k
        ptr = next;
971
16.2k
      }
972
16.2k
    }
973
16.2k
  }
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
959
329k
  void internal_clear() {
960
329k
    T *ptr;
961
329k
    T *next;
962
963
329k
    if (!empty()) {
964
0
      ptr = last->next;     // set to first
965
0
      last->next = nullptr; // break circle
966
0
      last = nullptr;       // set list empty
967
0
      while (ptr) {
968
0
        next = ptr->next;
969
0
        delete ptr;
970
0
        ptr = next;
971
0
      }
972
0
    }
973
329k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::internal_clear()
Line
Count
Source
959
178k
  void internal_clear() {
960
178k
    T *ptr;
961
178k
    T *next;
962
963
178k
    if (!empty()) {
964
69.4k
      ptr = last->next;     // set to first
965
69.4k
      last->next = nullptr; // break circle
966
69.4k
      last = nullptr;       // set list empty
967
457k
      while (ptr) {
968
387k
        next = ptr->next;
969
387k
        delete ptr;
970
387k
        ptr = next;
971
387k
      }
972
69.4k
    }
973
178k
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::internal_clear()
Line
Count
Source
959
200k
  void internal_clear() {
960
200k
    T *ptr;
961
200k
    T *next;
962
963
200k
    if (!empty()) {
964
66.8k
      ptr = last->next;     // set to first
965
66.8k
      last->next = nullptr; // break circle
966
66.8k
      last = nullptr;       // set list empty
967
951k
      while (ptr) {
968
884k
        next = ptr->next;
969
884k
        delete ptr;
970
884k
        ptr = next;
971
884k
      }
972
66.8k
    }
973
200k
  }
974
975
5.73G
  bool empty() const {
976
5.73G
    return !last;
977
5.73G
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK_RES>::empty() const
Line
Count
Source
975
117M
  bool empty() const {
976
117M
    return !last;
977
117M
  }
tesseract::IntrusiveForwardList<tesseract::ROW_RES>::empty() const
Line
Count
Source
975
270M
  bool empty() const {
976
270M
    return !last;
977
270M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::empty() const
Line
Count
Source
975
667M
  bool empty() const {
976
667M
    return !last;
977
667M
  }
tesseract::IntrusiveForwardList<tesseract::BLOCK>::empty() const
Line
Count
Source
975
394k
  bool empty() const {
976
394k
    return !last;
977
394k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::empty() const
Line
Count
Source
975
329M
  bool empty() const {
976
329M
    return !last;
977
329M
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::empty() const
Line
Count
Source
975
917M
  bool empty() const {
976
917M
    return !last;
977
917M
  }
tesseract::IntrusiveForwardList<tesseract::PARA>::empty() const
Line
Count
Source
975
66.0k
  bool empty() const {
976
66.0k
    return !last;
977
66.0k
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::empty() const
Line
Count
Source
975
1.48M
  bool empty() const {
976
1.48M
    return !last;
977
1.48M
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::empty() const
Line
Count
Source
975
12.8M
  bool empty() const {
976
12.8M
    return !last;
977
12.8M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::empty() const
Line
Count
Source
975
1.10G
  bool empty() const {
976
1.10G
    return !last;
977
1.10G
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::empty() const
Line
Count
Source
975
409M
  bool empty() const {
976
409M
    return !last;
977
409M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::empty() const
Line
Count
Source
975
36.7M
  bool empty() const {
976
36.7M
    return !last;
977
36.7M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::empty() const
Line
Count
Source
975
1.56G
  bool empty() const {
976
1.56G
    return !last;
977
1.56G
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::empty() const
Line
Count
Source
975
278M
  bool empty() const {
976
278M
    return !last;
977
278M
  }
tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::empty() const
Line
Count
Source
975
1.15M
  bool empty() const {
976
1.15M
    return !last;
977
1.15M
  }
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
975
2.12M
  bool empty() const {
976
2.12M
    return !last;
977
2.12M
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::empty() const
Line
Count
Source
975
14.9M
  bool empty() const {
976
14.9M
    return !last;
977
14.9M
  }
tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::empty() const
Line
Count
Source
975
4.62M
  bool empty() const {
976
4.62M
    return !last;
977
4.62M
  }
978
979
39.8M
  bool singleton() const {
980
39.8M
    return last ? (last == last->next) : false;
981
39.8M
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::singleton() const
Line
Count
Source
979
4.18M
  bool singleton() const {
980
4.18M
    return last ? (last == last->next) : false;
981
4.18M
  }
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::singleton() const
Line
Count
Source
979
893k
  bool singleton() const {
980
893k
    return last ? (last == last->next) : false;
981
893k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE>::singleton() const
Line
Count
Source
979
13.1M
  bool singleton() const {
980
13.1M
    return last ? (last == last->next) : false;
981
13.1M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::TO_BLOCK>::singleton() const
tesseract::IntrusiveForwardList<tesseract::WERD_RES>::singleton() const
Line
Count
Source
979
115k
  bool singleton() const {
980
115k
    return last ? (last == last->next) : false;
981
115k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::singleton() const
Line
Count
Source
979
19.4M
  bool singleton() const {
980
19.4M
    return last ? (last == last->next) : false;
981
19.4M
  }
tesseract::IntrusiveForwardList<tesseract::ROW>::singleton() const
Line
Count
Source
979
52.1k
  bool singleton() const {
980
52.1k
    return last ? (last == last->next) : false;
981
52.1k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::singleton() const
Line
Count
Source
979
863k
  bool singleton() const {
980
863k
    return last ? (last == last->next) : false;
981
863k
  }
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
979
1.76k
  bool singleton() const {
980
1.76k
    return last ? (last == last->next) : false;
981
1.76k
  }
tesseract::IntrusiveForwardList<tesseract::C_OUTLINE_FRAG>::singleton() const
Line
Count
Source
979
234k
  bool singleton() const {
980
234k
    return last ? (last == last->next) : false;
981
234k
  }
tesseract::IntrusiveForwardList<tesseract::SORTED_FLOAT>::singleton() const
Line
Count
Source
979
901k
  bool singleton() const {
980
901k
    return last ? (last == last->next) : false;
981
901k
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::FPSEGPT>::singleton() const
982
983
  void shallow_copy(      // dangerous!!
984
    IntrusiveForwardList *from_list) { // beware destructors!!
985
    last = from_list->last;
986
  }
987
988
  /***********************************************************************
989
 *              IntrusiveForwardList::assign_to_sublist
990
 *
991
 *  The list is set to a sublist of another list.  "This" list must be empty
992
 *  before this function is invoked.  The two iterators passed must refer to
993
 *  the same list, different from "this" one.  The sublist removed is the
994
 *  inclusive list from start_it's current position to end_it's current
995
 *  position.  If this range passes over the end of the source list then the
996
 *  source list has its end set to the previous element of start_it.  The
997
 *  extracted sublist is unaffected by the end point of the source list, its
998
 *  end point is always the end_it position.
999
 **********************************************************************/
1000
  void assign_to_sublist(       // to this list
1001
    Iterator *start_it, // from list start
1002
0
    Iterator *end_it) {  // from list end
1003
0
    constexpr ERRCODE LIST_NOT_EMPTY("Destination list must be empty before extracting a sublist");
1004
1005
0
    if (!empty()) {
1006
0
      LIST_NOT_EMPTY.error("IntrusiveForwardList.assign_to_sublist", ABORT);
1007
0
    }
1008
1009
0
    last = start_it->extract_sublist(end_it);
1010
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*)
1011
1012
    // # elements in list
1013
11.2M
  int32_t length() const {
1014
11.2M
    int32_t count = 0;
1015
11.2M
    if (last != nullptr) {
1016
9.15M
      count = 1;
1017
47.9M
      for (auto it = last->next; it != last; it = it->next) {
1018
38.7M
        count++;
1019
38.7M
      }
1020
9.15M
    }
1021
11.2M
    return count;
1022
11.2M
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::length() const
Line
Count
Source
1013
1.71M
  int32_t length() const {
1014
1.71M
    int32_t count = 0;
1015
1.71M
    if (last != nullptr) {
1016
1.70M
      count = 1;
1017
22.7M
      for (auto it = last->next; it != last; it = it->next) {
1018
21.0M
        count++;
1019
21.0M
      }
1020
1.70M
    }
1021
1.71M
    return count;
1022
1.71M
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::length() const
Line
Count
Source
1013
435k
  int32_t length() const {
1014
435k
    int32_t count = 0;
1015
435k
    if (last != nullptr) {
1016
325k
      count = 1;
1017
1.27M
      for (auto it = last->next; it != last; it = it->next) {
1018
953k
        count++;
1019
953k
      }
1020
325k
    }
1021
435k
    return count;
1022
435k
  }
tesseract::IntrusiveForwardList<tesseract::ICOORDELT>::length() const
Line
Count
Source
1013
261k
  int32_t length() const {
1014
261k
    int32_t count = 0;
1015
261k
    if (last != nullptr) {
1016
261k
      count = 1;
1017
522k
      for (auto it = last->next; it != last; it = it->next) {
1018
261k
        count++;
1019
261k
      }
1020
261k
    }
1021
261k
    return count;
1022
261k
  }
tesseract::IntrusiveForwardList<tesseract::BLOB_CHOICE>::length() const
Line
Count
Source
1013
8.79M
  int32_t length() const {
1014
8.79M
    int32_t count = 0;
1015
8.79M
    if (last != nullptr) {
1016
6.83M
      count = 1;
1017
23.3M
      for (auto it = last->next; it != last; it = it->next) {
1018
16.4M
        count++;
1019
16.4M
      }
1020
6.83M
    }
1021
8.79M
    return count;
1022
8.79M
  }
Unexecuted instantiation: tesseract::IntrusiveForwardList<tesseract::WERD_RES>::length() const
tesseract::IntrusiveForwardList<tesseract::WERD_CHOICE>::length() const
Line
Count
Source
1013
20.8k
  int32_t length() const {
1014
20.8k
    int32_t count = 0;
1015
20.8k
    if (last != nullptr) {
1016
20.8k
      count = 1;
1017
49.2k
      for (auto it = last->next; it != last; it = it->next) {
1018
28.3k
        count++;
1019
28.3k
      }
1020
20.8k
    }
1021
20.8k
    return count;
1022
20.8k
  }
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
1023
1024
  /***********************************************************************
1025
 *              IntrusiveForwardList::sort
1026
 *
1027
 *  Sort elements on list
1028
 *  NB If you don't like the const declarations in the comparator, coerce yours:
1029
 *   ( int (*)(const void *, const void *)
1030
 **********************************************************************/
1031
  void sort(          // sort elements
1032
    int comparator( // comparison routine
1033
752k
      const T *, const T *)) {
1034
    // Allocate an array of pointers, one per list element.
1035
752k
    auto count = length();
1036
1037
752k
    if (count > 0) {
1038
      // ptr array to sort
1039
634k
      std::vector<T *> base;
1040
634k
      base.reserve(count);
1041
1042
634k
      Iterator it(this);
1043
1044
      // Extract all elements, putting the pointers in the array.
1045
9.46M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1046
8.82M
        base.push_back(it.extract());
1047
8.82M
      }
1048
1049
      // Sort the pointer array.
1050
634k
      std::sort(base.begin(), base.end(),
1051
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1052
59.7M
        [&](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
1052
957k
        [&](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
1052
261k
        [&](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
1052
58.5M
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1053
1054
      // Rebuild the list from the sorted pointers.
1055
8.82M
      for (auto current : base) {
1056
8.82M
        it.add_to_end(current);
1057
8.82M
      }
1058
634k
    }
1059
752k
  }
tesseract::IntrusiveForwardList<tesseract::C_BLOB>::sort(int (*)(tesseract::C_BLOB const*, tesseract::C_BLOB const*))
Line
Count
Source
1033
229k
      const T *, const T *)) {
1034
    // Allocate an array of pointers, one per list element.
1035
229k
    auto count = length();
1036
1037
229k
    if (count > 0) {
1038
      // ptr array to sort
1039
120k
      std::vector<T *> base;
1040
120k
      base.reserve(count);
1041
1042
120k
      Iterator it(this);
1043
1044
      // Extract all elements, putting the pointers in the array.
1045
715k
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1046
594k
        base.push_back(it.extract());
1047
594k
      }
1048
1049
      // Sort the pointer array.
1050
120k
      std::sort(base.begin(), base.end(),
1051
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1052
120k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1053
1054
      // Rebuild the list from the sorted pointers.
1055
594k
      for (auto current : base) {
1056
594k
        it.add_to_end(current);
1057
594k
      }
1058
120k
    }
1059
229k
  }
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
1033
261k
      const T *, const T *)) {
1034
    // Allocate an array of pointers, one per list element.
1035
261k
    auto count = length();
1036
1037
261k
    if (count > 0) {
1038
      // ptr array to sort
1039
261k
      std::vector<T *> base;
1040
261k
      base.reserve(count);
1041
1042
261k
      Iterator it(this);
1043
1044
      // Extract all elements, putting the pointers in the array.
1045
783k
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1046
522k
        base.push_back(it.extract());
1047
522k
      }
1048
1049
      // Sort the pointer array.
1050
261k
      std::sort(base.begin(), base.end(),
1051
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1052
261k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1053
1054
      // Rebuild the list from the sorted pointers.
1055
522k
      for (auto current : base) {
1056
522k
        it.add_to_end(current);
1057
522k
      }
1058
261k
    }
1059
261k
  }
tesseract::IntrusiveForwardList<tesseract::BLOBNBOX>::sort(int (*)(tesseract::BLOBNBOX const*, tesseract::BLOBNBOX const*))
Line
Count
Source
1033
261k
      const T *, const T *)) {
1034
    // Allocate an array of pointers, one per list element.
1035
261k
    auto count = length();
1036
1037
261k
    if (count > 0) {
1038
      // ptr array to sort
1039
252k
      std::vector<T *> base;
1040
252k
      base.reserve(count);
1041
1042
252k
      Iterator it(this);
1043
1044
      // Extract all elements, putting the pointers in the array.
1045
7.96M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1046
7.70M
        base.push_back(it.extract());
1047
7.70M
      }
1048
1049
      // Sort the pointer array.
1050
252k
      std::sort(base.begin(), base.end(),
1051
        // all current comparators return -1,0,1, so we handle this correctly for std::sort
1052
252k
        [&](auto &&l, auto &&r) {return comparator(l, r) < 0; });
1053
1054
      // Rebuild the list from the sorted pointers.
1055
7.70M
      for (auto current : base) {
1056
7.70M
        it.add_to_end(current);
1057
7.70M
      }
1058
252k
    }
1059
261k
  }
1060
1061
  // Assuming list has been sorted already, insert new_link to
1062
  // keep the list sorted according to the same comparison function.
1063
  // Comparison function is the same as used by sort, i.e. uses double
1064
  // indirection. Time is O(1) to add to beginning or end.
1065
  // Time is linear to add pre-sorted items to an empty list.
1066
  // If unique is set to true and comparator() returns 0 (an entry with the
1067
  // same information as the one contained in new_link is already in the
1068
  // list) - new_link is not added to the list and the function returns the
1069
  // pointer to the identical entry that already exists in the list
1070
  // (otherwise the function returns new_link).
1071
  T *add_sorted_and_find(int comparator(const T *, const T *), bool unique,
1072
5.85M
    T *new_link) {
1073
    // Check for adding at the end.
1074
5.85M
    if (last == nullptr || comparator(last, new_link) < 0) {
1075
1.49M
      if (last == nullptr) {
1076
786k
        new_link->next = new_link;
1077
786k
      } else {
1078
705k
        new_link->next = last->next;
1079
705k
        last->next = new_link;
1080
705k
      }
1081
1.49M
      last = new_link;
1082
4.36M
    } else {
1083
      // Need to use an iterator.
1084
4.36M
      Iterator it(this);
1085
21.1M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1086
21.1M
        auto *link = it.data();
1087
21.1M
        int compare = comparator(link, new_link);
1088
21.1M
        if (compare > 0) {
1089
4.36M
          break;
1090
16.8M
        } else if (unique && compare == 0) {
1091
228
          return link;
1092
228
        }
1093
21.1M
      }
1094
4.36M
      if (it.cycled_list()) {
1095
0
        it.add_to_end(new_link);
1096
4.36M
      } else {
1097
4.36M
        it.add_before_then_move(new_link);
1098
4.36M
      }
1099
4.36M
    }
1100
5.85M
    return new_link;
1101
5.85M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::add_sorted_and_find(int (*)(tesseract::ViterbiStateEntry const*, tesseract::ViterbiStateEntry const*), bool, tesseract::ViterbiStateEntry*)
Line
Count
Source
1072
5.77M
    T *new_link) {
1073
    // Check for adding at the end.
1074
5.77M
    if (last == nullptr || comparator(last, new_link) < 0) {
1075
1.48M
      if (last == nullptr) {
1076
785k
        new_link->next = new_link;
1077
785k
      } else {
1078
703k
        new_link->next = last->next;
1079
703k
        last->next = new_link;
1080
703k
      }
1081
1.48M
      last = new_link;
1082
4.28M
    } else {
1083
      // Need to use an iterator.
1084
4.28M
      Iterator it(this);
1085
10.7M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1086
10.7M
        auto *link = it.data();
1087
10.7M
        int compare = comparator(link, new_link);
1088
10.7M
        if (compare > 0) {
1089
4.28M
          break;
1090
6.47M
        } else if (unique && compare == 0) {
1091
0
          return link;
1092
0
        }
1093
10.7M
      }
1094
4.28M
      if (it.cycled_list()) {
1095
0
        it.add_to_end(new_link);
1096
4.28M
      } else {
1097
4.28M
        it.add_before_then_move(new_link);
1098
4.28M
      }
1099
4.28M
    }
1100
5.77M
    return new_link;
1101
5.77M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::add_sorted_and_find(int (*)(tesseract::AmbigSpec const*, tesseract::AmbigSpec const*), bool, tesseract::AmbigSpec*)
Line
Count
Source
1072
76.1k
    T *new_link) {
1073
    // Check for adding at the end.
1074
76.1k
    if (last == nullptr || comparator(last, new_link) < 0) {
1075
1.54k
      if (last == nullptr) {
1076
304
        new_link->next = new_link;
1077
1.23k
      } else {
1078
1.23k
        new_link->next = last->next;
1079
1.23k
        last->next = new_link;
1080
1.23k
      }
1081
1.54k
      last = new_link;
1082
74.6k
    } else {
1083
      // Need to use an iterator.
1084
74.6k
      Iterator it(this);
1085
10.4M
      for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1086
10.4M
        auto *link = it.data();
1087
10.4M
        int compare = comparator(link, new_link);
1088
10.4M
        if (compare > 0) {
1089
74.3k
          break;
1090
10.3M
        } else if (unique && compare == 0) {
1091
228
          return link;
1092
228
        }
1093
10.4M
      }
1094
74.3k
      if (it.cycled_list()) {
1095
0
        it.add_to_end(new_link);
1096
74.3k
      } else {
1097
74.3k
        it.add_before_then_move(new_link);
1098
74.3k
      }
1099
74.3k
    }
1100
75.9k
    return new_link;
1101
76.1k
  }
1102
1103
  // Same as above, but returns true if the new entry was inserted, false
1104
  // if the identical entry already existed in the list.
1105
5.85M
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1106
5.85M
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1107
5.85M
  }
tesseract::IntrusiveForwardList<tesseract::ViterbiStateEntry>::add_sorted(int (*)(tesseract::ViterbiStateEntry const*, tesseract::ViterbiStateEntry const*), bool, tesseract::ViterbiStateEntry*)
Line
Count
Source
1105
5.77M
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1106
5.77M
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1107
5.77M
  }
tesseract::IntrusiveForwardList<tesseract::AmbigSpec>::add_sorted(int (*)(tesseract::AmbigSpec const*, tesseract::AmbigSpec const*), bool, tesseract::AmbigSpec*)
Line
Count
Source
1105
76.1k
  bool add_sorted(int comparator(const T *, const T *), bool unique, T *new_link) {
1106
76.1k
    return (add_sorted_and_find(comparator, unique, new_link) == new_link);
1107
76.1k
  }
1108
};
1109
1110
template <typename CLASSNAME>
1111
using ELIST = IntrusiveForwardList<CLASSNAME>;
1112
1113
// add TESS_API?
1114
// move templated lists to public include dirs?
1115
#define ELISTIZEH(T)                                        \
1116
  class T##_LIST : public IntrusiveForwardList<T> {         \
1117
  public:                                                   \
1118
    using IntrusiveForwardList<T>::IntrusiveForwardList;    \
1119
  };                                                        \
1120
  class T##_IT : public IntrusiveForwardList<T>::Iterator { \
1121
  public:                                                   \
1122
    using IntrusiveForwardList<T>::Iterator::Iterator;      \
1123
  };
1124
1125
} // namespace tesseract
1126
1127
#endif