Package mondrian.util
Class UnionIterator<T>
- java.lang.Object
-
- mondrian.util.UnionIterator<T>
-
- All Implemented Interfaces:
Iterator<T>
public class UnionIterator<T> extends Object implements Iterator<T>
Iterator over union of severalIterable
collections.Try, for instance, using the
over(java.lang.Iterable<? extends T>...)
helper method:List<String> names;
List<String> addresses;
for (Sstring s : UnionIterator.over(names, addresses)) { print(s);
}- Since:
- Apr 28, 2008
- Author:
- jhyde
-
-
Constructor Summary
Constructors Constructor Description UnionIterator(Iterable<? extends T>... iterables)
Creates a UnionIterator.UnionIterator(Collection<? extends T>... iterables)
Creates a UnionIterator over a list of collections.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
static <T> Iterable<T>
over(Iterable<? extends T>... iterables)
Returns the union of a list of iterables.static <T> Iterable<T>
over(Collection<? extends T>... collections)
Returns the union of a list of collections.void
remove()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
UnionIterator
public UnionIterator(Iterable<? extends T>... iterables)
Creates a UnionIterator.- Parameters:
iterables
- Array of iterables
-
UnionIterator
public UnionIterator(Collection<? extends T>... iterables)
Creates a UnionIterator over a list of collections.- Parameters:
iterables
- Array of collections
-
-
Method Detail
-
over
public static <T> Iterable<T> over(Iterable<? extends T>... iterables)
Returns the union of a list of iterables.You can use it like this:
Iterable<String> iter1; Iterable<String> iter2; for (String s : union(iter1, iter2)) { print(s); }
- Parameters:
iterables
- Array of one or more iterables- Returns:
- iterable over the union of the iterables
-
over
public static <T> Iterable<T> over(Collection<? extends T>... collections)
Returns the union of a list of collections.This method exists for code that will be retrowoven to run on JDK 1.4. Retroweaver has its own version of the
Iterable
interface, which is problematic since theCollection
classes don't implement it. This method solves some of these problems by working in terms of collections; retroweaver deals with these correctly.- Parameters:
collections
- Array of one or more collections- Returns:
- iterable over the union of the collections
- See Also:
over(Iterable[])
-
-