[Gambas-devel] Please Benoit i want this !!

Benoît Minisini gambas at ...1...
Fri Nov 28 21:12:43 CET 2014


Le 26/10/2014 11:53, Fabien Bodard a écrit :
> Private Function GetDiffArray(Array1 As Integer[], Array2 As
> Integer[]) As Integer[]
>
>    Dim aRet As New Integer[]
>    Dim i As Integer
>
>    For Each i In Array2
>      If Array1.Exist(i) Then Continue
>      aRet.Add(i)
>    Next
>    Return aRet
>
> End
>
>
>
> Is it possible to add this in a native way :
>
> MyArray1.Diff(MyArray2) as array ?
>
>
>
> For example in a string it will give
>
> Destination to do :
> [Dest1, Dest2, Dest3, Dest4]
>
> Destination Done
> [Dest1, Dest3]
>
> Dest remain :
> [Dest2, Dest4]
>
>
> I use this to manage a doc cache. In the view i have for example Doc10
> to Doc 16 showed.  If i scroll then the doclist change ... so i have
> to remove a part of the doc from the cache and then charge another
> one.
>
>
> Regards,
> Fabien
>

This is not simple. You want set operators on arrays, and arrays are not 
set. They can have the same elements more than once.

For example, if one set operator need to remove an element from an 
array, what should it do if the element is included twice? Remove the 
first one? Remove both?

Maybe a Set class? I don't know if Tobias put a Set class in its gb.data 
component...

A Set is not as simple as an array. It can be implemented as an array of 
bits (if your elements are integers not too big), an array of elements 
(if you don't have too many elements), or as a hash table that only 
store keys (only the absence or presence of the element is important).

-- 
Benoît Minisini




More information about the Devel mailing list