Java Iterable Size iterableSize(Iterable itrbl)

Here you can find the source of iterableSize(Iterable itrbl)

Description

Computes, in linear time, the length of an Iterable.

License

BSD License

Declaration

public static <E> int iterableSize(Iterable<E> itrbl) 

Method Source Code

//package com.java2s;
// Licensed under the Modified BSD Licence; see COPYING for details.

import java.util.Iterator;

public class Main {
    /** Computes, in linear time, the length of an
    <code>Iterable</code>.  This is done by iterating over all
    elements from <code>itrbl</code> and counting their number. */
    public static <E> int iterableSize(Iterable<E> itrbl) {
        int size = 0;
        for (Iterator<E> iter = itrbl.iterator(); iter.hasNext();) {
            iter.next();/*  w  w  w.  j a va2 s  .  c o m*/
            size++;
        }
        return size;
    }
}

Related

  1. getSingle(Iterable it)
  2. getSingleElementOrNull(Iterable coll)
  3. getSingleIfExist(Iterable iterable)
  4. getSingleOrNull(Iterable iterable)
  5. iterableSize(Iterable iterable)
  6. iterableSizeEq(Iterable itrbl, int k)
  7. singleOrNull(Iterable iterable)
  8. singleOrNull(Iterable iterable)
  9. size(final Iterable iterable)