Package edu.jas.util

Class KsubSetIterator<E>

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

    class KsubSetIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<java.util.List<E>>
    Power set iterator.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private E current  
      private java.util.Iterator<E> iter  
      int k  
      private java.util.Iterator<java.util.List<E>> recIter  
      (package private) java.util.List<E> rest  
      java.util.List<E> set
      data structure.
    • Constructor Summary

      Constructors 
      Constructor Description
      KsubSetIterator​(java.util.List<E> set, int k)
      KsubSetIterator constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Test for availability of a next subset.
      java.util.List<E> next()
      Get next subset.
      void remove()
      Remove the last subset returned from underlying set if allowed.
      • 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

      • set

        public final java.util.List<E> set
        data structure.
      • k

        public final int k
      • rest

        final java.util.List<E> rest
      • current

        private E current
      • recIter

        private java.util.Iterator<java.util.List<E>> recIter
      • iter

        private final java.util.Iterator<E> iter
    • Constructor Detail

      • KsubSetIterator

        public KsubSetIterator​(java.util.List<E> set,
                               int k)
        KsubSetIterator constructor.
        Parameters:
        set - generating set.
        k - subset size.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Test for availability of a next subset.
        Specified by:
        hasNext in interface java.util.Iterator<E>
        Returns:
        true if the iteration has more subsets, else false.
      • next

        public java.util.List<E> next()
        Get next subset.
        Specified by:
        next in interface java.util.Iterator<E>
        Returns:
        next subset.
      • remove

        public void remove()
        Remove the last subset returned from underlying set if allowed.
        Specified by:
        remove in interface java.util.Iterator<E>