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

[1]
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#frequency(java.util.Collection,
java.lang.Object)
------------------------------------------------------------------------------
"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