public class Iterate
extends java.lang.Object
| Constructor and Description |
|---|
Iterate() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Iterable<java.lang.Integer> |
count(int num)
Returns an iterator to be executed
num times. |
static <T> ItIterable<T> |
each(java.lang.Iterable<T> elements)
An iterator that has a value (
it.value()) and an index
(it.index()). |
static <T> ItIterable<T> |
each(T[] ary)
An iterator that has a value (
it.value()) and an index
(it.index()). |
static <T> java.lang.Iterable<T> |
over(java.lang.Iterable<T> elements)
Returns an Iterable (iterator) for the collection, which can be null.
|
static <T> java.lang.Iterable<T> |
over(T[] ary)
Returns an Iterable (iterator) for the C-style array, which can be null.
|
public static java.lang.Iterable<java.lang.Integer> count(int num)
num times.num - the number of times to iteratepublic static <T> java.lang.Iterable<T> over(T[] ary)
ary is null, an "empty" iterator will be returned.T - the type of elementsary - the array to iterate over; can be nulleach(T[])public static <T> java.lang.Iterable<T> over(java.lang.Iterable<T> elements)
coll is null, an "empty" iterator will be returned.T - the type of elementselements - the elements to iterate over; can be nulleach(T[])public static <T> ItIterable<T> each(T[] ary)
it.value()) and an index
(it.index()).
for (It<String> it : Iterate.each(array)) {
System.out.println("element #" + it.index() + ": " + it.value());
}
public static <T> ItIterable<T> each(java.lang.Iterable<T> elements)
it.value()) and an index
(it.index()).
for (It<String> it : Iterate.each(list)) {
System.out.println("element #" + it.index() + ": " + it.value());
}