![]() |
FInd duplicate array and a quick way to search item per line on file??
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. |
AW: FInd duplicate array and a quick way to search item per line on file??
Your first example is not sorted! But if it would be sorted then you're right.
-- EDIT You can use ![]() ![]() ![]() ![]() |
AW: FInd duplicate array and a quick way to search item per line on file??
Zitat:
Okey, I'll try. I have to check again that "AssignFile" doesn't load the file into memory. Thanks. |
AW: FInd duplicate array and a quick way to search item per line on file??
if each line of your file has the same length you can calculate at which position the data is.
To access the file a prefer TFileStream |
AW: FInd duplicate array and a quick way to search item per line on file??
Zitat:
so you have to check the previous and the next index(s). Greetings K-H |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:53 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz