
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
Since I do not know what type of array you use (obviously no standard array
since these are of fixed length without being able to "take out a value")
I'm using a TStringlist called "TheList" for example's sake here. The
routine supposes the list to be sorted as in your example.
for x:=1 to elementcount-1 do
if TheList[x]=TheList[x-1] then
TheList.delete(x)
else
inc(x,1);
Remember not to use a for-loop since a removed value shifts back the values
after it (decreases their index), and if you increase x after a delete, the
next value isn't compared.
"Laphan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi All
>
> I'm a bit new to Delphi (understatement) and I wondered if anybody could
> post me the best/fastest possible routine to remove all duplicates from an
> array, for example:
>
> I have the following array of values:
>
> 1
> 3
> 6
> 6
> 8
> 9
> 11
> 11
> 11
> 12
> etc..
>
> I want a routine that can efficiently take this array and strip it down
to:
>
> 1
> 3
> 6
> 8
> 9
> 11
> 12
> etc..
>
> Many thanks.
>
> Rgds
>
> Laphan
>
>
>
>
| <-- __Chronological__ --> | <-- __Thread__ --> |