commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hein Meling <hein.mel...@uis.no>
Subject [Commons-math] Why call the method valuesIterator()
Date Wed, 19 Oct 2005 11:59:26 GMT
Hi all,

I've just started using commons-math, and want to iterate over the set
of values in a Frequency object, but the method is called
valuesIterator() and not the usual iterator().  Why this change of
convention??

The reason I want it to be called iterator() is that I'm using it from
groovy, which support simplified iteration over objects that provide an
iterator() method.  That is, I could simply do:

freq.each { val ->
  println val + " " + freq.getCount(val)
}

With the current naming convention I have to do this:

    def iter = freq.valuesIterator()
    while (iter.hasNext()) {
      def val = iter.next()
      println val + " " + freq.getCount(x)
    }

Please consider changing this naming convention, or at least provide
both.

Thanks for reading,

Hein


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message