Реферат: Алгоритмы поиска в тексте

if (P[j]<>S[i+j-1]) and (P[j]<>'?') and (S[i+j-1]<>'?')

then Break

else if j = lp then

begin

Result := i;

Exit;

end;

end;

procedure WCMakeBMTable( var BMT : PBMTable;

const P : String);

var

i, j, lp, MaxShift, CurShift, SufPos : Integer;

Suffix : String;

begin

lp := Length(P);

GetMem(BMT, SizeOf(TIntVect)*lp);

if P[lp] = '?' then

for i := 0 to 255 do BMT^[lp-1][i] := 0

else

begin

for i := 0 to 255 do BMT^[lp-1][i] := lp;

for i := lp downto 1 do

if BMT^[lp-1][Byte(P[i])] = lp then

BMT^[lp-1][Byte(P[i])] := lp - i;

end;

MaxShift := lp;

for i := lp - 1 downto 1 do

begin

SetLength(Suffix, lp - i);

К-во Просмотров: 330
Бесплатно скачать Реферат: Алгоритмы поиска в тексте