Class ProductIterator<T>

  • All Implemented Interfaces:
    Iterator<java.util.List<T>>

    public class ProductIterator<T>
    extends java.lang.Object
    implements Iterator<java.util.List<T>>
    ProductIterator implements a product iterator, a composite iterator that generates all possible combinations of items produced by simpler iterators.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all registered iterators.
      ProductIterator<T> clone()
      Creates a copy of the iterator.
      boolean hasValue()
      Checks if the iterator is not exhausted (a value is available).
      void init()
      Initializes the iterator.
      Iterator<T> iterator​(int index)
      Returns the i-th iterator of the list.
      void next()
      Makes an iteration.
      void registerIterator​(Iterator<T> iterator)
      Registers the iterator.
      int size()
      Returns the number of the registered iterators.
      void stop()
      Stops the iterator.
      java.util.List<T> value()
      Returns the current value of the iterator.
      T value​(int index)
      Returns the value of the i-th iterator.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProductIterator

        public ProductIterator()
        Constructs a product iterator.
      • ProductIterator

        protected ProductIterator​(ProductIterator<T> other)
        Constructs a copy of the product iterator.
        Parameters:
        other - the iterator to be copied.
    • Method Detail

      • registerIterator

        public void registerIterator​(Iterator<T> iterator)
        Registers the iterator.
        Parameters:
        iterator - the iterator to be registered.
      • clear

        public void clear()
        Removes all registered iterators.
      • size

        public int size()
        Returns the number of the registered iterators.
        Returns:
        the number of the registered iterators.
      • iterator

        public Iterator<T> iterator​(int index)
        Returns the i-th iterator of the list.
        Parameters:
        index - the iterator index.
        Returns:
        the i-th iterator of the list.
      • init

        public void init()
        Description copied from interface: Iterator
        Initializes the iterator.
        Specified by:
        init in interface Iterator<T>
      • hasValue

        public boolean hasValue()
        Description copied from interface: Iterator
        Checks if the iterator is not exhausted (a value is available).
        Specified by:
        hasValue in interface Iterator<T>
        Returns:
        true if the iterator is not exhausted; false otherwise.
      • value

        public T value​(int index)
        Returns the value of the i-th iterator.
        Parameters:
        index - the iterator index.
        Returns:
        the value of the i-th iterator.
      • value

        public java.util.List<T> value()
        Description copied from interface: Iterator
        Returns the current value of the iterator.
        Specified by:
        value in interface Iterator<T>
        Returns:
        the current value of the iterator.
      • next

        public void next()
        Description copied from interface: Iterator
        Makes an iteration.
        Specified by:
        next in interface Iterator<T>
      • stop

        public void stop()
        Description copied from interface: Iterator
        Stops the iterator.
        Specified by:
        stop in interface Iterator<T>
      • clone

        public ProductIterator<T> clone()
        Description copied from interface: Iterator
        Creates a copy of the iterator.
        Specified by:
        clone in interface Iterator<T>
        Overrides:
        clone in class java.lang.Object
        Returns:
        A copy of the iterator.