Class FilteredIterable<X>

  • Type Parameters:
    X - The type of elements to iterate over.
    All Implemented Interfaces:
    java.lang.Iterable<X>

    public class FilteredIterable<X>
    extends java.lang.Object
    implements java.lang.Iterable<X>
    This class allows to iterate of any type of Iterable in a filtered way. More specifically, given a whitelist of indices, this class allows to iterate only over the elements listed in that whitelist. This util works for all kind of Iterables. The basic idea is to avoid copying data for iterating over subsets only. Note that this does only work for iterables with a fixed order, i.e., no HashSets!
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredIterable​(java.lang.Iterable<X> wrappedIterable, java.util.List<java.lang.Integer> filteredIndices)
      Standard c'tor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.Integer> getFilteredIndices()
      Getter for the list of filtered indices.
      java.util.Iterator<X> iterator()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • FilteredIterable

        public FilteredIterable​(java.lang.Iterable<X> wrappedIterable,
                                java.util.List<java.lang.Integer> filteredIndices)
        Standard c'tor.
        Parameters:
        wrappedIterable - The iterable which is to be wrapped and filtered.
        filteredIndices - The list of indices that are whitelisted and are expected to be returned when iterating over the iterable.
    • Method Detail

      • iterator

        public java.util.Iterator<X> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<X>
      • getFilteredIndices

        public java.util.List<java.lang.Integer> getFilteredIndices()
        Getter for the list of filtered indices.
        Returns:
        The list of filtered indices.