MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / _utstring_BuildTableR

Function _utstring_BuildTableR

libCacheSim/dataStructure/ut/utstring.h:211–247  ·  view source on GitHub ↗

Build KMP table from right to left. */

Source from the content-addressed store, hash-verified

209
210/* Build KMP table from right to left. */
211UTSTRING_UNUSED static void _utstring_BuildTableR(
212 const char *P_Needle,
213 size_t P_NeedleLen,
214 long *P_KMP_Table)
215{
216 long i, j;
217
218 i = P_NeedleLen - 1;
219 j = i + 1;
220 P_KMP_Table[i + 1] = j;
221 while (i >= 0)
222 {
223 while ( (j < (long) P_NeedleLen) && (P_Needle[i] != P_Needle[j]) )
224 {
225 j = P_KMP_Table[j + 1];
226 }
227 i--;
228 j--;
229 if (i >= 0)
230 {
231 if (P_Needle[i] == P_Needle[j])
232 {
233 P_KMP_Table[i + 1] = P_KMP_Table[j + 1];
234 }
235 else
236 {
237 P_KMP_Table[i + 1] = j;
238 }
239 }
240 else
241 {
242 P_KMP_Table[i + 1] = j;
243 }
244 }
245
246 return;
247}
248
249
250/* Search data from left to right. ( Multiple search mode. ) */

Callers 1

utstring_findRFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected