@Override public void forEach(Procedure<? super T> procedure) { procedure.value(this.element1); procedure.value(this.element2); procedure.value(this.element3); procedure.value(this.element4); procedure.value(this.element5); procedure.value(this.element6); }
public static <T> void forEach( Iterable<T> iterable, int from, int to, Procedure<? super T> procedure) { if (from < 0 || to < 0) { throw new IllegalArgumentException("Neither from nor to may be negative."); } Iterator<T> iterator = IteratorIterate.advanceIteratorTo(iterable.iterator(), from); int i = from; while (iterator.hasNext() && i <= to) { procedure.value(iterator.next()); i++; } }