Курсовая работа: Хэш поиск

begin

for i:=1 to 10 do mas[i]:=TList.Create(aKey);

end;

function TMas.HeshFunction(aKey:string):integer; //Hesh-функция

var x,i,j:integer;

begin

x:= 0;

for i:=1 to length(aKey) do x:=ord(aKey[i])+x; // Определениезначениястроки

j:=(x mod 10)+1; //Определение элемента

result:=j;

end;

function TMas.Add(aKey:string;found:byte):byte;

var j:integer;

begin

j:=HeshFunction(aKey);

if Found=0 then

begin

if mas[j].Head.next<>nil then result:=j else result:=0;

mas[j].AddFirst(aKey);

end else

if found=1 then

begin

if mas[j].Head.next<>nil then result:=j else result:=0;

mas[j].AddLast(aKey);

end;

end;

function Tmas.Search(aKey:string;var aCount:integer):string;

var j:integer; Cur:TItem;

begin

К-во Просмотров: 908
Бесплатно скачать Курсовая работа: Хэш поиск