For best performance, loop over index from 0 to length-1 instead of using
the For Each construct.


2014-05-18 14:43 GMT+02:00 Benoît Minisini <gam...@users.sourceforge.net>:

> 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
>
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to