{*
查找指定的值是否在当前数组中(数组已经是有序的)
*}
function SearchData(dataList: array of integer; id: longint ): Boolean;
var
idMid: integer;
idLow, idHigh: integer;
begin
idLow := 0;
idHigh := High(dataList);
while ( idLow <= idHigh ) do
begin
if idLow = idHigh then
begin
if dataList[ idLow ] = id then
begin
Result := True;
end
else
begin
Result := False;
end;
Exit;
end;
idMid := ( idLow + idHigh ) div 2;
if dataList[ idMid ] = id then
begin
Result := True;
Exit;
end;
if dataList[ idMid ] > id then idHigh := idMid – 1;
if dataList[ idMid ] < id then idLow := idMid + 1;
end;
Result := False;
end;