|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.myjavatools.lib.foundation.Iterators
public class Iterators
Iterators is a utility class that contains static methods for iterators
Collection,
Iterator,
Filter| Nested Class Summary | |
|---|---|
static class |
Iterators.EmptyIterator<T>
EmptyIterator is a helper class that does not contain any elements and throws an exception when next() is called. |
| Constructor Summary | |
|---|---|
Iterators()
|
|
| Method Summary | ||
|---|---|---|
static
|
cat(java.util.Collection<? extends T>... elements)
Concatenates vararg Collections into one List |
|
static
|
cat(java.lang.Iterable<? extends java.util.Iterator<T>> outerLoop)
Creates an Iterator view of an Iterable consisting of Iterators |
|
static
|
cat(java.lang.Iterable<? extends X>... elements)
Concatenates vararg Iterables into one List |
|
static
|
cat(java.util.Iterator<T>... components)
Creates an Iterator view of a sequence of Iterators |
|
static java.lang.Iterable<java.lang.Character> |
chars(java.lang.CharSequence sequence)
returns an iterable good for using in a foreach loop |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Iterators()
| Method Detail |
|---|
public static <T> java.util.Iterator<T> cat(java.lang.Iterable<? extends java.util.Iterator<T>> outerLoop)
outerLoop - Iterable <? extends Iterator<T>> source iterators
cat(iterator1, iterator2, iterator3) and
with arrays: cat(iterators[]).
Example:
List list1 = Arrays.asList(new String[] {"One", "Two", "Three"});
List list2 = Arrays.asList(new String[] {"Four", "Five", "Six"});
List list3 = Arrays.asList(new String[] {"One", "Two", "Three", "Four", "Five", "Six"}
cat(Arrays.asList(new Iterator {list1.iterator(), list2.iterator()}))
returns the same as list3.iterator().public static <T> java.util.Iterator<T> cat(java.util.Iterator<T>... components)
components - Iterator[] source iterators
cat(iterator1, iterator2, iterator3) and
with arrays: cat(iterators[]).
Example:
List list1 = Arrays.asList(new String[] {"One", "Two", "Three"});
List list2 = Arrays.asList(new String[] {"Four", "Five", "Six"});
List list3 = Arrays.asList(new String[] {"One", "Two", "Three", "Four", "Five", "Six"}
cat(list1.iterator(), list2.iterator())
returns the same as list3.iterator().public static <X> java.lang.Iterable<X> cat(java.lang.Iterable<? extends X>... elements)
elements - Iterable<? extends X>...
cat(Arrays.asList(new String[] {"a", "b", "c"}), Arrays.asList(new String[] {"b", "a", "d"}))
returns the same Iterable as Arrays.asList(new String[] {"a", "b", "c", "b", "a", "d"}).public static <T> java.util.Collection<T> cat(java.util.Collection<? extends T>... elements)
elements - Collection<? extends T>...
cat(Arrays.asList(new String[] {"a", "b", "c"}), Arrays.asList(new String[] {"b", "a", "d"}))
returns the same Collection as Arrays.asList(new String[] {"a", "b", "c", "b", "a", "d"}).public static java.lang.Iterable<java.lang.Character> chars(java.lang.CharSequence sequence)
sequence - CharSequence to scan
for (char c : chars("this is an example"){
System.out.println("Character " + c);
}
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||