Here you can find the source of size(Iterable> it)
Parameter | Description |
---|---|
it | the iterable |
public static int size(Iterable<?> it)
//package com.java2s; /**//from www . j a va2 s . c om * LICENSE INFORMATION * * Copyright 2005-2008 by FZI (http://www.fzi.de). Licensed under a BSD license * (http://www.opensource.org/licenses/bsd-license.php) <OWNER> = Max V?lkel * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, * Germany <YEAR> = 2010 * * Further project information at http://semanticweb.org/wiki/RDF2Go */ import java.util.Iterator; public class Main { /** * Count statements in iterable 'it' * * @param it the iterable * @return the size */ public static int size(Iterable<?> it) { int count = 0; Iterator<?> i = it.iterator(); while (i.hasNext()) { i.next(); count++; } return count; } /** * Count statements in iterator 'it' * * @param i the iterator * @return the size */ public static int size(Iterator<?> i) { int count = 0; while (i.hasNext()) { i.next(); count++; } return count; } }