@@ -94,6 +94,56 @@ static const uint8_t* const next_table =
94
94
95
95
namespace tesseract {
96
96
97
+ /* *
98
+ * Sort Key array in ascending order using heap sort
99
+ * algorithm. Also sort Index array that is tied to
100
+ * the key array.
101
+ * @param n Number of elements to sort
102
+ * @param ra Key array [1..n]
103
+ * @param rb Index array [1..n]
104
+ * @return none
105
+ */
106
+ static void
107
+ HeapSort (int n, int ra[], int rb[]) {
108
+ int i, rra, rrb;
109
+ int l, j, ir;
110
+
111
+ l = (n >> 1 ) + 1 ;
112
+ ir = n;
113
+ for (;;) {
114
+ if (l > 1 ) {
115
+ rra = ra[--l];
116
+ rrb = rb[l];
117
+ }
118
+ else {
119
+ rra = ra[ir];
120
+ rrb = rb[ir];
121
+ ra[ir] = ra[1 ];
122
+ rb[ir] = rb[1 ];
123
+ if (--ir == 1 ) {
124
+ ra[1 ] = rra;
125
+ rb[1 ] = rrb;
126
+ return ;
127
+ }
128
+ }
129
+ i = l;
130
+ j = l << 1 ;
131
+ while (j <= ir) {
132
+ if (j < ir && ra[j] < ra[j + 1 ])
133
+ ++j;
134
+ if (rra < ra[j]) {
135
+ ra[i] = ra[j];
136
+ rb[i] = rb[j];
137
+ j += (i = j);
138
+ }
139
+ else
140
+ j = ir + 1 ;
141
+ }
142
+ ra[i] = rra;
143
+ rb[i] = rrb;
144
+ }
145
+ }
146
+
97
147
// Encapsulation of the intermediate data and computations made by the class
98
148
// pruner. The class pruner implements a simple linear classifier on binary
99
149
// features by heavily quantizing the feature space, and applying
@@ -1017,7 +1067,6 @@ void IntegerMatcher::DisplayProtoDebugInfo(
1017
1067
InitProtoDisplayWindowIfReqd ();
1018
1068
}
1019
1069
1020
-
1021
1070
for (ProtoSetIndex = 0 ; ProtoSetIndex < ClassTemplate->NumProtoSets ;
1022
1071
ProtoSetIndex++) {
1023
1072
ProtoSet = ClassTemplate->ProtoSets [ProtoSetIndex];
@@ -1182,53 +1231,3 @@ float IntegerMatcher::ApplyCNCorrection(float rating, int blob_length,
1182
1231
matcher_multiplier * normalization_factor / 256.0 ) /
1183
1232
(blob_length + matcher_multiplier);
1184
1233
}
1185
-
1186
- /* *
1187
- * Sort Key array in ascending order using heap sort
1188
- * algorithm. Also sort Index array that is tied to
1189
- * the key array.
1190
- * @param n Number of elements to sort
1191
- * @param ra Key array [1..n]
1192
- * @param rb Index array [1..n]
1193
- * @return none
1194
- */
1195
- void
1196
- HeapSort (int n, int ra[], int rb[]) {
1197
- int i, rra, rrb;
1198
- int l, j, ir;
1199
-
1200
- l = (n >> 1 ) + 1 ;
1201
- ir = n;
1202
- for (;;) {
1203
- if (l > 1 ) {
1204
- rra = ra[--l];
1205
- rrb = rb[l];
1206
- }
1207
- else {
1208
- rra = ra[ir];
1209
- rrb = rb[ir];
1210
- ra[ir] = ra[1 ];
1211
- rb[ir] = rb[1 ];
1212
- if (--ir == 1 ) {
1213
- ra[1 ] = rra;
1214
- rb[1 ] = rrb;
1215
- return ;
1216
- }
1217
- }
1218
- i = l;
1219
- j = l << 1 ;
1220
- while (j <= ir) {
1221
- if (j < ir && ra[j] < ra[j + 1 ])
1222
- ++j;
1223
- if (rra < ra[j]) {
1224
- ra[i] = ra[j];
1225
- rb[i] = rb[j];
1226
- j += (i = j);
1227
- }
1228
- else
1229
- j = ir + 1 ;
1230
- }
1231
- ra[i] = rra;
1232
- rb[i] = rrb;
1233
- }
1234
- }
0 commit comments