[Gambas-user] Feature request: Array.Frequency

Benoît Minisini gambas at ...1...
Sun May 18 14:43:49 CEST 2014


Le 18/05/2014 13:44, Patrik Karlsson a écrit :
> I'm converting a Java app of mine to Gambas and I could not find any
> equivalent to Java's Collections.frequency [1].
>
> So I wrote this function for Integer[]:
>
> Private Function Frequency(aArray As Integer[], iValue As Integer) As
> Integer
>
>    Dim iCount As Integer
>    Dim iItem As Integer
>
>    For Each iItem In aArray
>      If iItem = iValue Then
>        Inc iCount
>      Endif
>    Next
>
>    Return iCount
>
> End
>
> Would it be possible to add Frequency as a read only property to gb.Array?
>
> /Patrik
>

Why don't you do that in Gambas using JIT compiler ?

-- 
Benoît Minisini




More information about the User mailing list