This is mnoGoSearch's cache of https://lists.gambas-basic.org/pipermail/user/2017-June/060675.html. It is a snapshot of the page as it appeared during last crawling. The current page could have changed in the meantime.

Last modified: Fri, 30 Jun 2017, 17:58:36 CEST    Size: 5383
[Gambas-user] I need a hint on how to deleted duplicate items in a array

[Gambas-user] I need a hint on how to deleted duplicate items in a array

Gianluigi bagonergi at ...626...
Fri Jun 30 17:58:36 CEST 2017


Sorry Tobias,
other explanations are not necessary.
I would not be able to understand :-(
I accept what you already explained to me as a dogma and I will try to put
it into practice by copying your code :-).

Thanks again.

Gianluigi

2017-06-30 17:44 GMT+02:00 Gianluigi <bagonergi at ...626...>:

>
> 2017-06-30 17:21 GMT+02:00 Tobias Boege <taboege at ...626...>:
>
>>
>> I wouldn't say there is anything *wrong* with it, but it also has
>> quadratic
>> worst-case running time. You use String[].Push() which is just another
>> name
>> for String[].Add(). Adding an element to an array (the straightforward
>> way)
>> is done by extending the space of that array by one further element and
>> storing the value there. But extending the space of an array could
>> potentially
>> require you to copy the whole array somewhere else (where you have enough
>> free memory at the end of the array to enlarge it). Doing worst-case
>> analysis,
>> we have to assume that this bad case always occurs.
>>
>> If you fill an array with n values, e.g.
>>
>>   Dim a As New Integer[]
>>   For i = 1 To n
>>     a.Add(i)
>>   Next
>>
>> then you loop n times and in the i-th iteration there will be already
>> i-many elements in your array. Adding one further element to it will,
>> in the worst case, require i copy operations to be performed. 9-year-old
>> C.F. Gauss will tell you that the amount of store operations is about n^2.
>>
>>
> Tobias you are always kind and thank you very much.
> Is possible for you to explain this more elementarily, for me (a poorly
> educated boy :-) )
>
>
>
>> And your function does two jobs simultaneously but only returns the result
>> of one of the jobs. The output you get is only worth half the time you
>> spent.
>>
>>
> I did two functions in one, just to save space, this is a simple example.
> :-)
>
> Regards
> Gianluigi
>



More information about the User mailing list