Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fast copy from hash to listview?
    primarykey
    data
    text
    <p>There is a hash pas file <a href="http://gpdelphiunits.googlecode.com/svn-history/r4/trunk/src/GpStringHash.pas" rel="nofollow">http://gpdelphiunits.googlecode.com/svn-history/r4/trunk/src/GpStringHash.pas</a></p> <p>We can create hash and add key - value </p> <p>Question 1: We want to know how to iterate key - value and copy data to listview.</p> <p>Question 2: is there a way to fast copy like assign method to it?</p> <p>Thank you very much in advance.</p> <p>Dear gabr, Thank you so much for your immediate reply and your hash file. Is there doc or help files or examples or demo for your code ? Thank you so much again. </p> <hr> <p>Just test, I do not know where i did wrong Thank you so much. I just used your code but there is the following error prompt. Or I made some mistakes:</p> <pre><code>procedure TForm8.ab; var a: TGpStringHash; i,j, fr:integer; k: string; enlist: TGpStringHashenumerator; kv: TGpStringHashKV; begin a:=TGpStringHash.Create; kv:=TGpStringHashKV.Create; enlist:= TGpStringHashenumerator.Create(a); for j:=1 to 10 do begin if a.HasKey(inttostr(j)) then begin fr:=a.ValueOf(inttostr(j)); a.Update(inttostr(j),fr+1); end else begin a.Add(inttostr(j),1); end; end; for i:=0 to a.Count -1 do begin kv:=enlist.GetCurrent; memo1.Lines.Add(kv.Key + inttostr(kv.value) ); end; end; /// Division by Zero ERROr ///FindBucket(const key: string): cardinal; </code></pre> <p>ANSWER: You're using enumerator improperly. Don't instantiate it in front and always use MoveNext to move to the next element.</p> <pre><code>// fill 'a' as above enlist := TGpStringHashenumerator.Create(a); while enList.MoveNext do begin kv:=enlist.GetCurrent; memo1.Lines.Add(kv.Key + inttostr(kv.value) ); end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload