|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.myjavatools.lib.foundation.Iterators
public abstract 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 Collection |
|
static
|
cat(java.util.Collection<java.util.Collection<? extends T>> elements)
Concatenates a collection of collections into one Collection |
|
static
|
cat(java.lang.Iterable<? extends java.util.Iterator<? extends T>> outerLoop)
Creates an Iterator view of an Iterable consisting of Iterators |
|
static
|
cat(java.lang.Iterable<? extends T>... elements)
Concatenates vararg Iterables into one List |
|
static
|
cat(java.util.Iterator<? extends T>... components)
Creates an Iterator view of a sequence of Iterators |
|
static java.lang.Iterable<java.lang.Character> |
chars(java.lang.CharSequence sequence)
Deprecated. This iterable has been moved to Strings |
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<? extends T>> outerLoop)
outerLoop
- Iterable <? extends Iterator<? extends 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<? extends T>... components)
components
- Iterator<? extends 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(list1.iterator(), list2.iterator())
returns the same as list3.iterator().public static <T> java.lang.Iterable<T> cat(java.lang.Iterable<? extends T>... elements)
elements
- Iterable<? extends T>...
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<T>...
cat(Arrays.asList("a", "b", "c"), Arrays.asList("b", "a", "d"))
returns the same Collection as Arrays.asList("a", "b", "c", "b", "a", "d")
.public static <T> java.util.Collection<T> cat(java.util.Collection<java.util.Collection<? extends T>> elements)
elements
- Collection<? extends Collection<? extends T>>...
cat(Arrays.asList(Arrays.asList("a", "b", "c"), Arrays.asList("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 |