Package mondrian.util
Class UnionIterator<T>
- java.lang.Object
-
- mondrian.util.UnionIterator<T>
-
- All Implemented Interfaces:
java.util.Iterator<T>
public class UnionIterator<T> extends java.lang.Object implements java.util.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(java.lang.Iterable<? extends T>... iterables)
Creates a UnionIterator.UnionIterator(java.util.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> java.lang.Iterable<T>
over(java.lang.Iterable<? extends T>... iterables)
Returns the union of a list of iterables.static <T> java.lang.Iterable<T>
over(java.util.Collection<? extends T>... collections)
Returns the union of a list of collections.void
remove()
-
-
-
Constructor Detail
-
UnionIterator
public UnionIterator(java.lang.Iterable<? extends T>... iterables)
Creates a UnionIterator.- Parameters:
iterables
- Array of iterables
-
UnionIterator
public UnionIterator(java.util.Collection<? extends T>... iterables)
Creates a UnionIterator over a list of collections.- Parameters:
iterables
- Array of collections
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<T>
-
over
public static <T> java.lang.Iterable<T> over(java.lang.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> java.lang.Iterable<T> over(java.util.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[])
-
-