Class CombinationIterator<T>

java.lang.Object
org.evrete.util.CombinationIterator<T>
Type Parameters:
T - The type of the elements generated by the source iterators.
All Implemented Interfaces:
Iterator<T[]>

public class CombinationIterator<T> extends Object implements Iterator<T[]>
An iterator that generates all possible combinations of elements from source objects.
  • Constructor Details

    • CombinationIterator

      public CombinationIterator(Class<T> type, S[] sources, Function<S,Iterator<T>> iteratorFunction)
      Class constructor
      Parameters:
      type - type of the resulting array
      sources - an array of sources
      iteratorFunction - a mapping function to create iterators from sources
    • CombinationIterator

      public CombinationIterator(S[] sources, T[] sharedResultArray, Function<S,Iterator<T>> iteratorFunction)
      Class constructor with shared result array that will be updated on each next() operation
      Parameters:
      sources - an array of sources
      sharedResultArray - a shared result array
      iteratorFunction - a mapping function to create iterators from sources
    • CombinationIterator

      public CombinationIterator(T[] sharedResultArray, IntFunction<Iterator<T>> iteratorFunction)
      Class constructor with shared result array that will be updated on each next() operation
      Parameters:
      sharedResultArray - a shared result array
      iteratorFunction - a mapping function to create iterators by array index
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • advanceIterator

      protected T advanceIterator(int index)
    • next

      public T[] next()
      Specified by:
      next in interface Iterator<T>