Class EnumerationAbstract

    • Field Summary

      Fields 
      Modifier and Type Field Description
      int[] currTupleOfIdxs
      The current tuple composed of indexes (of values)
      protected boolean indexesMatchValues
      Indicates if indexes match values (i.e., if the value at index i is always i).
      protected Boolean nextTuple
      Indicates if the method hasNext() has already been called.
    • Constructor Summary

      Constructors 
      Constructor Description
      EnumerationAbstract​(int tupleLength, boolean indexesMatchValues)
      Builds an object that can be used for enumerating tuples, each of them with the specified length.
    • Field Detail

      • nextTuple

        protected Boolean nextTuple
        Indicates if the method hasNext() has already been called. This is not the case if the value of this field is null. Otherwise, the value of this field indicates the presence (Boolean.TRUE) or the absence (Boolean.FALSE) of another tuple already computed.
      • currTupleOfIdxs

        public final int[] currTupleOfIdxs
        The current tuple composed of indexes (of values)
      • indexesMatchValues

        protected final boolean indexesMatchValues
        Indicates if indexes match values (i.e., if the value at index i is always i).
    • Constructor Detail

      • EnumerationAbstract

        public EnumerationAbstract​(int tupleLength,
                                   boolean indexesMatchValues)
        Builds an object that can be used for enumerating tuples, each of them with the specified length.
        Parameters:
        tupleLength - the length of each tuple in the enumeration
        indexesMatchValues - true iff indexes (of values) and values match, i.e. if the value at index i is always i)
    • Method Detail

      • computeFirstTuple

        protected abstract void computeFirstTuple()
        Computes the first tuple (called at reset time).
      • reset

        public void reset()
        Resets the object, so as to be able to iterate again over all tuples of the enumeration.
      • valAt

        protected abstract int valAt​(int pos)
        Returns the value of the current tuple at the specified position.
        Parameters:
        pos - the position of an integer in the tuple
        Returns:
        the value of the current tuple at the specified position
      • hasNext

        public abstract boolean hasNext()
        Specified by:
        hasNext in interface Iterator<int[]>
      • next

        public int[] next()
        DO NOT MODIFY the tuple that is returned.
        Specified by:
        next in interface Iterator<int[]>
      • execute

        public void execute​(java.util.function.Consumer<int[]> c)
      • toArray

        public int[][] toArray​(java.util.function.Predicate<int[]> p)
        Returns an array with all tuples that can be enumerated while being accepted by the specified predicate.
        Parameters:
        p - a predicate used to test the tuples in the enumeration
        Returns:
        an array with all tuples that can be enumerated while being accepted by the specified predicate
      • toArray

        public int[][] toArray()
        Returns an array with all tuples that can be enumerated. The array is lexicographically sorted.
        Returns:
        an array with all tuples that can be enumerated
      • displayAllTuples

        public void displayAllTuples()
        Displays all tuples of this enumeration.