I'd like to propose the following simple additions to the
o.a.c.c.IteratorUtils
class.
The following is a simple convenience method for counting the number of
elements
in an iteration, something that I find myself recreating somewhat
frequently:
public static
int countElements (final Iterator iter) {
int cnt = 0;
while (iter.hasNext ()) {
cnt ++;
}
return cnt;
}
There isn't an EnumeratorUtils present that might contain an equivalent:
public static
int countElements (final Enumerator enum) {
int cnt = 0;
while (enum.hasNext ()) {
cnt ++;
}
return cnt;
}
Or the slightly less performant:
public static
int countElements (final Enumerator enum) {
return IteratorUtils.countElements (asIterator (enum));
}
Thoughts?
--lee
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]