procedure TForm1.Button1Click(Sender: TObject); var A,B:TStringList; i,k:Integer; s :string; begin A := TStringList.Create; B := TStringList.Create; try //Sorted属性一定要设为True //设成True后List在搜索的时候就会以2分法去查找 //这样速度就会快点。暂时想到的就只有这一个方法。 A.Sorted := True; B.Sorted := True; for i:=0 to B.Count -1 do begin s := B.Strings[i]; if A.Find(s,k) then A.Delete(K); end; finally A.Free; B.Free; end; end;
for i:=0 to B.Count -1 do begin s := B.Strings[i]; if A.Indexof(S)>-1 then A.Delete(K); end; 也可以
procedure TForm1.Button1Click(Sender: TObject);
var
A,B:TStringList;
i,k:Integer;
s :string;
begin
A := TStringList.Create;
B := TStringList.Create;
try
//Sorted属性一定要设为True
//设成True后List在搜索的时候就会以2分法去查找
//这样速度就会快点。暂时想到的就只有这一个方法。
A.Sorted := True;
B.Sorted := True;
for i:=0 to B.Count -1 do
begin
s := B.Strings[i];
if A.Find(s,k) then
A.Delete(K);
end;
finally
A.Free;
B.Free;
end;
end;
begin
s := B.Strings[i];
if A.Indexof(S)>-1 then
A.Delete(K);
end;
也可以