Class Combinations.SingletonIterator

  • All Implemented Interfaces:
    java.util.Iterator<int[]>
    Enclosing class:
    Combinations

    private static class Combinations.SingletonIterator
    extends java.lang.Object
    implements java.util.Iterator<int[]>
    Iterator with just one element to handle degenerate cases (full array, empty array) for combination iterator.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean more
      True on initialization, false after first call to next.
      private int n
      Number of elements of the singleton array.
    • Constructor Summary

      Constructors 
      Constructor Description
      SingletonIterator​(int n)
      Create a singleton iterator providing the given array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      int[] next()  
      void remove()
      Unsupported.
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
    • Field Detail

      • n

        private final int n
        Number of elements of the singleton array.
      • more

        private boolean more
        True on initialization, false after first call to next.
    • Constructor Detail

      • SingletonIterator

        SingletonIterator​(int n)
        Create a singleton iterator providing the given array.
        Parameters:
        n - Size of the singleton array returned by the iterator.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<int[]>
        Returns:
        true until next is called the first time, then false.
      • next

        public int[] next()
        Specified by:
        next in interface java.util.Iterator<int[]>
        Returns:
        the singleton at the first activation.
        Throws:
        java.util.NoSuchElementException - after the first activation.
      • remove

        public void remove()
        Unsupported.
        Specified by:
        remove in interface java.util.Iterator<int[]>
        Throws:
        java.lang.UnsupportedOperationException - Remove is not supported.