[Gambas-user] Feature request: Array.Frequency

Patrik Karlsson pata.karlsson at ...626...
Sun May 18 13:44:13 CEST 2014


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)



More information about the User mailing list