code: public static <E> boolean iterableSizeEq(Iterable<E> itrbl, int k) {
  	// 1) try to iterate k times over itrbl;
  	Iterator<E> it = itrbl.iterator();
  	for(int i = 0; i < k; i++) {
  	   if(!it.hasNext()) return false;
  	   it.next();
  	}
  	// 2) next check that there are no more elements in itrbl
  	return !it.hasNext();
      }
docs: Checks whether the iterable <code>itrbl</code> has exactly
  <code>k</code> elements.  Instead of computing the length of
  <code>itrbl</code> (complexity: linear in the length) and
  comparing it with <code>k</code>, we try to iterate exactly
  <code>k</code> times and next check that <code>itrbl</code> is
  exhausted.
  
  Complexity: linear in <code>k</code>.  Hence, this test is
  very fast for small <code>k</code>s.