Java Utililty Methods Iterator Size

List of utility methods to do Iterator Size

Description

The list of methods to do Iterator Size are organized into topic(s).

Method

longcount(final Iterator iterator)
count
long ix = 0;
for (; iterator.hasNext(); ++ix)
    iterator.next();
return ix;
intcount(Iterator triples)
count
int count = 0;
while (triples.hasNext()) {
    triples.next();
    count++;
return count;
longcount(Iterator iterator)
Determines the number of elements in an iteration.
if (iterator == null) {
    return 0;
long count = 0;
while (iterator.hasNext()) {
    ++count;
    iterator.next();
return count;
intcount(Iterator it)
count
if (it == null) {
    throw new IllegalArgumentException("it == null");
int count = 0;
while (it.hasNext()) {
    it.next();
    count++;
return count;
longcounter(final Iterator iterator)
Count the number of objects in an iterator.
long counter = 0;
try {
    while (true) {
        iterator.next();
        counter++;
} catch (final NoSuchElementException e) {
return counter;
intsize(final Iterator iter)
Returns the number of elements in the iterator sequence.
if (iter == null) {
    throw new NullPointerException();
int count = 0;
while (iter.hasNext()) {
    iter.next();
    count++;
return count;
intsize(Iterator source)
Get the size of an iterator (number of items in it).
int result = 0;
while (source.hasNext()) {
    source.next();
    ++result;
return result;
intsize(Iterator iterator)
Resolves the size of a given Iterator by iterating over it.
int retval = 0;
if (iterator != null) {
    for (; iterator.hasNext(); iterator.next()) {
        retval++;
return retval;
longsize(Iterator iterator)
size
long size = 0;
while (iterator.hasNext()) {
    iterator.next();
    size += 1;
return size;