Java Iterator Size size(Iterator source)

Here you can find the source of size(Iterator source)

Description

Get the size of an iterator (number of items in it).

License

Open Source License

Parameter

Parameter Description
source a parameter

Declaration

public static int size(Iterator source) 

Method Source Code

//package com.java2s;
// License & terms of use: http://www.unicode.org/copyright.html#License

import java.util.Iterator;

public class Main {
    /**//from  w  w w. j  a va2 s .  c  o  m
     * Get the size of an iterator (number of items in it).
     * @param source
     * @return
     */
    public static int size(Iterator source) {
        int result = 0;
        while (source.hasNext()) {
            source.next();
            ++result;
        }
        return result;
    }
}

Related

  1. count(Iterator triples)
  2. count(Iterator iterator)
  3. count(Iterator it)
  4. counter(final Iterator iterator)
  5. size(final Iterator iter)
  6. size(Iterator iterator)
  7. size(Iterator iterator)