Jussi Lahtinen ha scritto:
> Meaning like this? Should be faster!
>
> Dim col As New Collection
>
> For ii = 0 To iMyArray.Max
> col.Add(iMyArray[ii], iMyArray[ii])
> Next
>
> iMyArray.Clear()
>
> For Each ii In col
> iMyArray.Add(ii)
> Next
>
>
> Jussi
>
>
> 2009/8/21 Benoît Minisini :
>
>>> N
Meaning like this? Should be faster!
Dim col As New Collection
For ii = 0 To iMyArray.Max
col.Add(iMyArray[ii], iMyArray[ii])
Next
iMyArray.Clear()
For Each ii In col
iMyArray.Add(ii)
Next
Jussi
2009/8/21 Benoît Minisini :
>> Now I use algorithm like this (maybe not optimal);
>>
>> Dim ii
> 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
hey Jussi,
if of course you prefer the integer approach rather than my approach
you could try this one.
--
Dim tmpInitial as Integer
tmpInitial = iMyArray.Find("my item")
iMyArray[tmpInitial] &= "-b
hey Jussi,
I've tried a similar technique filtering about 5230 filenames and with my
old HyperThreaded p...@3ghz
It works pretty good for me :)
as I said give it a try :)
Regards
Dimitris
On Fri, Aug 21, 2009 at 1:49 PM, Jussi Lahtinen wrote:
> Usually string handling is slower than integer,
Usually string handling is slower than integer, although I haven't
test that in Gambas.
Jussi
On Fri, Aug 21, 2009 at 22:43, Dimitris Anogiatis wrote:
> Hey Jussi,
>
> If you want to find the duplicate values in an array... give this trick a
> try
>
> 1) turn the array into a string
> 2) store i
Hey Jussi,
If you want to find the duplicate values in an array... give this trick a
try
1) turn the array into a string
2) store it in a temp string variable
3) find the first occurence of the value you want
4) put the rest of the string in another temp variable
5) do a replace(tempString, "what
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
What I do also to avoid duplicates is check the array before you add
the new entry to it
IF MyArray.Find("YourString") = -1 THEN MyArray.Add("YourString")
--
Let Crystal Reports handle the reporting - Free Crystal Reports
> Hi!
> Gambas has VERY good set of methods regarding arrays, but something is
> missing! I'd like to see iMyArray.RemoveDuplicates. Because with large
> arrays this simple task
> is pretty CPU intensive!
> What do you think?
>
>
> Jussi
>
Why do you have duplicates inside your array?
--
Benoît
Can you use the array.find() method?
maybe loop through the array?
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
Hi!
Gambas has VERY good set of methods regarding arrays, but something is missing!
I'd like to see iMyArray.RemoveDuplicates. Because with large arrays
this simple task
is pretty CPU intensive!
What do you think?
Jussi
12 matches
Mail list logo