本文整理自网络,侵删。
Find是折半查找 速度应该是最快了而indexof默认是 for 循环所有item了。 但find使用前必须先排序 sort 否则返回 index错误。
示例如下:
var lst:TStringList ; i:Integer ;begin lst:=TStringList.Create ; try lst:=TStringList.Create ; lst.CaseSensitive :=true; lst.Delimiter :=','; lst.DelimitedText :=Edit1.Text ; ShowMessage(IntToStr(lst.IndexOf(Edit2.Text) )); lst.Sort ; if lst.Find(Edit2.Text ,i) then ShowMessage(IntToStr(i)); finally lst.Free ; end;eidt2 内容 如下字符串 010a,010A,200a,200b,905a
来源:https://www.cnblogs.com/chinawcs/archive/2011/09/21/2184104.html
相关阅读 >>
Delphi 用 directshow 获取本机的视频摄像设备列表
Delphi searchrec.attr and fadirectory
Delphi 利用createservice写与桌面交互的win32服务
Delphi 使用firedac打开sqlite数据库韩文、阿拉伯文出现乱码的处理方法
更多相关阅读请进入《Delphi》频道 >>