Skip to content

Commit e1e56d9

Browse files
committed
Remove local function declarations from intmatcher.h
This requires moving the local function HeapSort to the beginning. Signed-off-by: Stefan Weil <[email protected]>
1 parent 2ba194c commit e1e56d9

File tree

2 files changed

+50
-69
lines changed

2 files changed

+50
-69
lines changed

src/classify/intmatcher.cpp

+50-51
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,56 @@ static const uint8_t* const next_table =
9494

9595
namespace tesseract {
9696

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+
97147
// Encapsulation of the intermediate data and computations made by the class
98148
// pruner. The class pruner implements a simple linear classifier on binary
99149
// features by heavily quantizing the feature space, and applying
@@ -1017,7 +1067,6 @@ void IntegerMatcher::DisplayProtoDebugInfo(
10171067
InitProtoDisplayWindowIfReqd();
10181068
}
10191069

1020-
10211070
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
10221071
ProtoSetIndex++) {
10231072
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
@@ -1182,53 +1231,3 @@ float IntegerMatcher::ApplyCNCorrection(float rating, int blob_length,
11821231
matcher_multiplier * normalization_factor / 256.0) /
11831232
(blob_length + matcher_multiplier);
11841233
}
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-
}

src/classify/intmatcher.h

-18
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,4 @@ class IntegerMatcher {
176176
uint32_t evidence_mult_mask_;
177177
};
178178

179-
/**----------------------------------------------------------------------------
180-
Private Function Prototypes
181-
----------------------------------------------------------------------------**/
182-
void IMDebugConfiguration(INT_FEATURE FeatureNum,
183-
uint16_t ActualProtoNum,
184-
uint8_t Evidence,
185-
BIT_VECTOR ConfigMask,
186-
uint32_t ConfigWord);
187-
188-
void IMDebugConfigurationSum(INT_FEATURE FeatureNum,
189-
uint8_t *FeatureEvidence,
190-
int32_t ConfigCount);
191-
192-
void HeapSort (int n, int ra[], int rb[]);
193-
194-
/**----------------------------------------------------------------------------
195-
Global Data Definitions and Declarations
196-
----------------------------------------------------------------------------**/
197179
#endif

0 commit comments

Comments
 (0)