Adding a skipZero() method to all the functions is probably better here, because that will be faster than an instanceof check, and easier to document than other interfaces.
On Tue, Mar 2, 2010 at 1:22 AM, Sean Owen <sro...@gmail.com> wrote: > How about merely a flag/method on BinaryFunction / UnaryFunction? or > DoubleDoubleFunction? (and why do we have DoubleDoubleFunction and > BinaryFunction?) This would be simpler and avoid instanceof. > We have DoubleDoubleFunction because it was in Colt, we have BinaryFunction because we had it before Colt. I made one extend the other to integrate a bit better. We should remove DoubleDoubleFunction at our convenience, as long as all the colt stuff is properly migrated over to BinaryFunction. Ditto for UnaryFunction and DoubleFunction. > And while we're in the neighborhood, thinking about streamlining, I > don't see why it.hasNext() is checked but it.next() is also checked > for null. The latter should not happen. > This is certainly true (although there were bugs earlier in which you could return null - you actually fixed some of those, Sean, by changing them to throw NoSuchElementException, as they should, in that case). -jake