jpaul.DataStructs
Class ImmutableCompoundIterable<A,B>
java.lang.Object
   jpaul.DataStructs.ImmutableCompoundIterable<A,B>
jpaul.DataStructs.ImmutableCompoundIterable<A,B>
- All Implemented Interfaces: 
- java.lang.Iterable<B>
- public class ImmutableCompoundIterable<A,B> 
- extends java.lang.Object- implements java.lang.Iterable<B>
ImmutableCompoundIterable allows the construction of an
   IMMUTABLE Iterable by merging several smaller
   Iterables.  Given an iterable with elements
   a0, a1, ..., ak, and a
   function f that transforms each ai into
   an iterable, the ImmutableCompoundIterable will contain all
   elements from f(a0), followed by all the elements from
   f(a1) and so on.
   
The elements of a ImmutableCompoundIterable are generated
   lazily, as we iterate over them.  This technique is better than
   eager iteration in the case when (1) f is simple; (2)
   the original Iterable changes dynamically; (3) the
   number of traversals is small; or (3) the number of elements is very
   large.
   
 Note on immutability: While it is possible to
   implement a mutable CompoundIterable (i.e., the user is able to
   remove elements), that would be very hard to specify: e.g., what if
   the function always returns a brand-new Iterable that
   ignores the past removals?
- Version:
- $Id: ImmutableCompoundIterable.java,v 1.3 2006/03/14 02:29:31 salcianu Exp $
- Author:
- Alexandru Salcianu - salcianu@alum.mit.edu
 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
 
ImmutableCompoundIterable
public ImmutableCompoundIterable(java.lang.Iterable<A> collA,
                                 Function<A,java.lang.Iterable<B>> a2iter)
- Creates an ImmutableCompoundIterable.
 
- Parameters:
- collA- An iterable of elements of type- A.
- a2iter- A function that transforms each element from- collAinto an- Iterableof- Bs.
 
iterator
public java.util.Iterator<B> iterator()
- 
- Specified by:
- iteratorin interface- java.lang.Iterable<B>
 
- 
 
toString
public java.lang.String toString()
- 
- Overrides:
- toStringin class- java.lang.Object
 
- 
 
Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu