Package mondrian.util
Class UnionIterator<T>
java.lang.Object
mondrian.util.UnionIterator<T>
- All Implemented Interfaces:
Iterator<T>
Iterator over union of several
Iterable
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
ConstructorDescriptionUnionIterator
(Iterable<? extends T>... iterables) Creates a UnionIterator.UnionIterator
(Collection<? extends T>... iterables) Creates a UnionIterator over a list of collections. -
Method Summary
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 Details
-
UnionIterator
Creates a UnionIterator.- Parameters:
iterables
- Array of iterables
-
UnionIterator
Creates a UnionIterator over a list of collections.- Parameters:
iterables
- Array of collections
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
over
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
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:
-