English 中文(简体)
如何摆脱这一 lo?
原标题:How to skip out of this loop?
  • 时间:2010-11-28 13:42:22
  •  标签:
  • delphi

这是一份分类清单,在德尔菲亚有500万件。 如何用同样的预设词快速搜寻物品,然后跳出 lo?

名单如下:

aa.....
ab cd//from here
ab kk
ab li
ab mn
ab xy// to here
ac xz
...

我指的是如何快速找到和复制有预设的 a和空档的物品。 一个b项的保修指数在双倍研究中。 ab c至bxy的指数通过双轨检索。

非常感谢。

Edit: We thank all for your answers.

最佳回答

如果你想很快的话,不要在TListView中储存你的数据。

利用TStringList储存你的名单,然后使用TList语进行虚拟播放。

阅读TStringList.Items[]比阅读TListView要快几倍。 项目[]财产。

如果你确信名单上不存在任何无效项目,则使用:

procedure Extract(List, Dest: TStrings; Char1, Char2: char);
var i,j: integer;
    V: cardinal;
type PC = {$ifdef UNICODE}PCardinal{$else}PWord{$endif};
begin
  V := ord(Char1)+ord(Char2) shl (8*sizeof(char));
  Dest.BeginUpdate;
  Dest.Clear;
  for i := 0 to List.Count-1 do begin
  if PC(pointer(List[i]))^=V then begin
    for j := i to List.Count-1 do begin
      Dest.Add(List[j]);
      if PC(pointer(List[j]))^<>V then
        break; // end the for j := loop
     end;
     break; // end the for i := loop
  end;
  Dest.EndUpdate;
end;

你们可以采用双轨搜索方法,以更快的速度进行。 但是,由于PWord()的骗局,在500万件物品清单中,你获得了通知。

请注意,PC(职称(List[i])^=V是较快的拷贝(List[i],1,2)=Char1+Char2,因为在比较期间没有设立临时护卫。 但是,它只有在没有名单(i)=,即没有点人(List[i])=nil的情况下才能运作。

我增加了1美元(1美元)UNICODE}和大小(果园),以便用所有版本的Delphi(2009年之前和之后)汇编这一法典。

问题回答

为了停止运行,使用<条码>突破<><>条码>指令,<条码>Exit也很有用,可以离开整个功能,特别是当你有多个避风港时。 作为最后的手段,你可以使用<代码>goto,跳出几个封顶的通道,继续履行同样的职能。

如果您使用<条码>,同时又使用或<条码>,请填写而不是<条码>。 顺便说一句,你可以把你确定中途停留条件的另一条 con子:

i := 0;
found := False;
while (i < count) and not found do begin
    // search for items
    found := True;
    // more stuff
    Inc(i);
end;




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签