edu.rice.cs.plt.iter
Class FilteredIterable<T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.AbstractIterable<T>
      extended by edu.rice.cs.plt.iter.FilteredIterable<T>
All Implemented Interfaces:
Composite, java.io.Serializable, java.lang.Iterable<T>

public class FilteredIterable<T>
extends AbstractIterable<T>
implements java.lang.Iterable<T>, Composite, java.io.Serializable

An Iterable containing all the values in the provided Iterable for which the provided Predicate holds. Because the size cannot be determined without traversing the list, does not implement SizedIterable.

See Also:
Serialized Form

Constructor Summary
FilteredIterable(java.lang.Iterable<? extends T> iterable, Predicate<? super T> predicate)
           
 
Method Summary
 int compositeHeight()
          Get the maximum path length from this node to a leaf.
 int compositeSize()
          Get the number of nodes in the tree rooted at this node.
 FilteredIterator<T> iterator()
           
static
<T> FilteredIterable<T>
make(java.lang.Iterable<? extends T> iterable, Predicate<? super T> predicate)
          Call the constructor (allows T to be inferred)
static
<T> SnapshotIterable<T>
makeSnapshot(java.lang.Iterable<? extends T> iterable, Predicate<? super T> predicate)
          Create a FilteredIterable and wrap it in a SnapshotIterable, forcing immediate evaluation of the filter.
 
Methods inherited from class edu.rice.cs.plt.iter.AbstractIterable
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilteredIterable

public FilteredIterable(java.lang.Iterable<? extends T> iterable,
                        Predicate<? super T> predicate)
Method Detail

iterator

public FilteredIterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

compositeHeight

public int compositeHeight()
Description copied from interface: Composite
Get the maximum path length from this node to a leaf.

Specified by:
compositeHeight in interface Composite

compositeSize

public int compositeSize()
Description copied from interface: Composite
Get the number of nodes in the tree rooted at this node. Always 1 or greater.

Specified by:
compositeSize in interface Composite

make

public static <T> FilteredIterable<T> make(java.lang.Iterable<? extends T> iterable,
                                           Predicate<? super T> predicate)
Call the constructor (allows T to be inferred)


makeSnapshot

public static <T> SnapshotIterable<T> makeSnapshot(java.lang.Iterable<? extends T> iterable,
                                                   Predicate<? super T> predicate)
Create a FilteredIterable and wrap it in a SnapshotIterable, forcing immediate evaluation of the filter.