Einzelnen Beitrag anzeigen

user

Registriert seit: 13. Jul 2010
25 Beiträge
 
Delphi 2 Desktop
 
#1

FInd duplicate array and a quick way to search item per line on file??

  Alt 19. Nov 2010, 10:20
For example I have an sorted array.
array[0]=1
array[1]=3
array[2]=2
array[3]=2
array[4]=4

First,
I use binary search to find an item. I found array[2]. I want to find duplicate item from the array, so I check the next index, if the value of next index doesn't match with array[2], it mean no duplicate item found. Am in right way to find duplicate item?

Second,
I got the duplicate items : array[2] and array[3]. I store them in new array or maybe in stringlist.
I have file contain :
aa
bb
cc
dd
ee

Now, I want to get the value of third line from the file (third line = array[2]). I want to get the value of forth line from the file (forth line = array[3]). The point is I want to retrieve the value from line based on index of duplicate array.

How to do this properly? I don't want to load all lines to stringlist to get the index, because if I have >5000 lines, the memory consumption will large.

Thanks.
  Mit Zitat antworten Zitat