[Gambas-user] To the wish list...

Benoît Minisini gambas at ...1...
Fri Aug 21 22:22:53 CEST 2009


> Now I use algorithm like this (maybe not optimal);
>
> Dim ii As Integer
> Dim jj As Integer
> Dim bRemove As Boolean
>
> While ii < iMyArray.Count
>
>  jj = 0
>  bRemove = False
>  While jj < iMyArray.Count
>   If ii <> jj And iMyArray[ii] = iMyArray[jj] Then
>   iMyArray.Remove(ii)
>   bRemove = True
>   Else
>   Inc jj
>   Endif
>  Wend
>
> If bRemove = False Then
> Inc ii
> Endif
> Wend
>
>
> Good point Benôit. Array is populated from file, but maybe I should use
> .Find() before .Add().
>
>
> Jussi
>

You should use a collection to detect duplicates, otherwise your algorithm is 
O(n^2)

Regards,

-- 
Benoît




More information about the User mailing list