Interface ProblemAPIOnVals

    • Method Detail

      • vals

        default int[] vals​(Object... objects)
        Builds and returns a 1-dimensional array of integers from the specified sequence of parameters. Each element of the sequence can be an Integer, a Range, an array (of any dimension), a Stream (or IntStream), a collection, etc. All integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        objects - a sequence of objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesIn

        default int[] valuesIn​(Object object,
                               Object... otherObjects)
        Builds and returns a 1-dimensional array of integers from the specified sequence of parameters. Each element of the sequence can be an Integer, a Range, an array (of any dimension), a Stream (or IntStream), a collection, etc. All integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        object - an object
        otherObjects - a sequence of objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default <T> int[] valuesFrom​(java.util.stream.Stream<T> stream,
                                     java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified stream. Each object of the stream is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        stream - a stream of objects
        f - a function mapping objects of the stream into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default int[] valuesFrom​(java.util.stream.IntStream stream,
                                 java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified stream. Each integer of the stream is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        stream - a stream of integers
        f - a function mapping integers of the stream into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default <T> int[] valuesFrom​(T[] t,
                                     java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified array. Each object of the array is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        t - a 1-dimensional array of objects
        f - a function mapping objects of the array into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default <T> int[] valuesFrom​(Collection<T> c,
                                     java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified collection. Each object of the collection is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        c - a collection of objects
        f - a function mapping objects of the collection into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default int[] valuesFrom​(int[] t,
                                 java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified array. Each integer of the array is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        t - a 1-dimensional array of integers
        f - a function mapping integers of the array into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default int[] valuesFrom​(char[] t,
                                 java.util.function.Function<Character,​Object> f)
      • valuesFrom

        default int[] valuesFrom​(Range r,
                                 java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified range. Each integer of the range is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        r - a range
        f - a function mapping integers of the range into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • valuesFrom

        default int[] valuesFrom​(Range.Rangesx2 r2,
                                 java.util.function.BiFunction<Integer,​Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified double range. Each pair of integers of the double range is mapped to another object by the specified function. Then, all integers are collected and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        r2 - a double range
        f - a function mapping pairs of integers of the double range into other objects
        Returns:
        a 1-dimensional array formed of collected integers (occurrences of null being discarded}
      • singleValuesIn

        default int[] singleValuesIn​(Object... objects)
        Builds and returns a 1-dimensional array of integers from the specified sequence of parameters. Each element of the sequence can be an Integer, a Range, an array (of any dimension), a Stream (or IntStream), a collection, etc. All integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        objects - an array (varargs) of objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default <T> int[] singleValuesFrom​(java.util.stream.Stream<T> stream,
                                           java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified stream. Each object of the stream is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        stream - a stream of objects
        f - a function mapping objects of the stream into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default int[] singleValuesFrom​(java.util.stream.IntStream stream,
                                       java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified stream. Each integer of the stream is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        stream -
        f - a function mapping integers of the stream into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default <T> int[] singleValuesFrom​(T[] t,
                                           java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified array. Each object of the stream is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        t - a 1-dimensional array of objects
        f - a function mapping objects of the array into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default <T> int[] singleValuesFrom​(Collection<T> c,
                                           java.util.function.Function<T,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified collection. Each object of the collection is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        c - a collection of objects
        f - a function mapping objects of the collection into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default int[] singleValuesFrom​(int[] t,
                                       java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified array. Each integer of the array is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        t - a 1-dimensional array of integers
        f - a function mapping integers of the array into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • singleValuesFrom

        default int[] singleValuesFrom​(Range r,
                                       java.util.function.Function<Integer,​Object> f)
        Builds and returns a 1-dimensional array of integers from the specified range. Each integer of the range is mapped to another object by the specified function. Then, all integers are collected, sorted, made distinct and concatenated to form a 1-dimensional array. null values are discarded.
        Parameters:
        r - a range
        f - a function mapping integers of the range into other objects
        Returns:
        a 1-dimensional array formed of distinct sorted collected integers (occurrences of null being discarded}
      • select

        default int[] select​(int[] t,
                             int fromIndex,
                             int toIndex)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value at an index i going from the fromIndex argument (inclusive) to the toIndex argument (exclusive).
        Parameters:
        t - a 1-dimensional array of integers
        fromIndex - the index of the first value (inclusive) to be selected
        toIndex - the index of the last value (exclusive) to be selected
        Returns:
        a 1-dimensional array of integers
      • select

        default int[] select​(int[] t,
                             int[] indexes)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value at an index i present in the indexes argument.
        Parameters:
        t - a 1-dimensional array of integers
        indexes - the indexes of the values to be selected
        Returns:
        a 1-dimensional array of integers
      • select

        default int[] select​(int[] t,
                             FunctionalInterfaces.Intx1Predicate p)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value that satisfies the specified predicate.
        Parameters:
        t - a 1-dimensional array of integers
        p - a predicate allowing us to test if a value v in the array must be selected
        Returns:
        a 1-dimensional array of integers
      • select

        default int[][] select​(int[][] m,
                               java.util.function.Predicate<int[]> p)
        Builds and returns a 2-dimensional array of integers, obtained by selecting from the specified array any row (tuple) that satisfies the specified predicate.
        Parameters:
        m - a 2-dimensional array of integers
        p - a predicate allowing us to test if a row (tuple) in the array must be selected
        Returns:
        a 2-dimensional array of integers
      • select

        default int[] select​(Range r,
                             FunctionalInterfaces.Intx1Predicate p)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified range any value that satisfies the specified predicate.
        Parameters:
        r - a range of integers
        p - a predicate allowing us to test if a value in the range must be selected
        Returns:
        a 1-dimensional array of integers
      • selectFromIndexing

        default int[] selectFromIndexing​(int[] t,
                                         FunctionalInterfaces.Intx1Predicate p)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value at an index i that satisfies the specified predicate.
        Parameters:
        t - a 1-dimensional array of integers
        p - a predicate allowing us to test if a value at index i must be selected
        Returns:
        a 1-dimensional array of integers
      • selectFromIndexing

        default int[] selectFromIndexing​(int[][] m,
                                         FunctionalInterfaces.Intx2Predicate p)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value at an index (i,j) that satisfies the specified predicate.
        Parameters:
        m - a 2-dimensional array of integers
        p - a predicate allowing us to test if a value at index (i,j) must be selected
        Returns:
        a 1-dimensional array of integers
      • selectFromIndexing

        default int[] selectFromIndexing​(int[][][] c,
                                         FunctionalInterfaces.Intx3Predicate p)
        Builds and returns a 1-dimensional array of integers, obtained by selecting from the specified array any value at an index (i,j,k) that satisfies the specified predicate.
        Parameters:
        c - a 3-dimensional array of integers
        p - a predicate allowing us to test if a value at index (i,j,k) must be selected
        Returns:
        a 1-dimensional array of integers
      • columnOf

        default int[] columnOf​(int[][] m,
                               int idColumn)
        Selects from the specified 2-dimensional array the column at the specified index.
        Parameters:
        m - a 2-dimensional array of integers
        idColumn - the index of a column
        Returns:
        the column from the specified 2-dimensional array, at the specified index
      • repeat

        default int[] repeat​(int value,
                             int length)
        Builds a 1-dimensional array of in by putting/repeating in it length occurrences of value.
        Parameters:
        value - the value to be repeated
        length - the number of times the value must be repeated
        Returns:
        a 1-dimensional array of the specified length only containing the specified value
      • dub

        default int[][] dub​(int[] values)
        Returns a 2-dimensional array obtained from the specified 1-dimensional array after replacing each value with an array of length 1 only containing this value. For example, dubbing [2,3,1] yields [[2],[3],[1]].
        Parameters:
        values - a 1 dimensional array of integers
        Returns:
        a 2-dimensional array of integers by replacing each value of the specified array into an array simply containing this value
      • dub

        default String[][] dub​(String[] values)
        Returns a 2-dimensional array obtained from the specified 1-dimensional array after replacing each value with an array of length 1 only containing this value. For example, dubbing ["red","green","blue"] yields [["red"],["green"],["blue"]].
        Parameters:
        values - a 1 -dimensional n array of strings
        Returns:
        a 2-dimensional array of strings by replacing each value of the specified array into an array simply containing this value
      • transpose

        default int[][] transpose​(int[]... m)
        Returns the transpose of the specified 2-dimensional array.
        Parameters:
        m - a 2-dimensional array of integers
        Returns:
        the transpose of the specified 2-dimensional array
      • distinctSorted

        @Deprecated
        default int[] distinctSorted​(int... t)
        Deprecated.
      • distinctSorted

        @Deprecated
        default int[] distinctSorted​(int[][] m)
        Deprecated.
      • allCartesian

        default int[][] allCartesian​(int[] nValues)
        Builds an array containing all tuples from the Cartesian product defined from the specified numbers of values. Each tuple will contain a value at position i in the range 0 to nValues[i].length-1.
        Parameters:
        nValues - indicates how many values are possible at each position
        Returns:
        an array containing all tuples from the Cartesian product defined from the specified number of values
      • allCartesian

        default int[][] allCartesian​(int[] nValues,
                                     java.util.function.Predicate<int[]> p)
        Builds an array containing the tuples from the Cartesian product (defined from the specified numbers of values) that respect the specified predicate. Each tuple will contain a value at position i in the range 0 to nValues[i].length-1.
        Parameters:
        nValues - indicates how many values are possible at each position
        p - a predicate used to select tuples
        Returns:
        an array containing the tuples from the Cartesian product (defined from the specified number of values) that respect the specified predicate
      • allCartesian

        default int[][] allCartesian​(int nValues,
                                     int tupleLength)
        Builds an array containing all tuples from the Cartesian product defined from the specified number of values. Each tuple has the specified length, and all values are taken in the range 0 to nValues-1.
        Parameters:
        nValues - the number of values used to form tuples
        tupleLength - the length of each tuple
        Returns:
        an array containing all tuples from the Cartesian product defined from the specified number of values and length
      • allCartesian

        default int[][] allCartesian​(int nValues,
                                     int tupleLength,
                                     java.util.function.Predicate<int[]> p)
        Builds an array containing the tuples from the Cartesian product (defined from the specified numbers of values and length) that respect the specified predicate. Each tuple has the specified length, and all values are taken in the range 0 to nValues-1.
        Parameters:
        nValues - the number of values used to form tuples
        tupleLength - the length of each tuple
        p - a predicate used to select tuples
        Returns:
        an array containing the tuples from the Cartesian product (defined from the specified number of values and length) that respect the specified predicate
      • allCombinations

        default int[][] allCombinations​(int[] nValues)
        Builds an array containing all combinations that can be obtained from the specified number of values.
        Parameters:
        nValues - the number of possible different values at each position of the tuples. These numbers must be in an increasing order (and are usually all equal)
        Returns:
        an array containing all combinations obtained from the specified number of values
      • allCombinations

        default int[][] allCombinations​(int nValues,
                                        int tupleLength)
        Builds an array containing all combinations that can be obtained from the specified number of values. Each tuple (combination) has the specified length, and all values are taken in the range 0 to nValues-1.
        Parameters:
        nValues - the number of values used to form combinations
        tupleLength - the length of each combination
        Returns:
        an array containing all combinations obtained from the specified number of values and length
      • allPermutations

        default int[][] allPermutations​(int[] nValues)
        Builds an array containing all permutations that can be obtained from the specified number of values. Each tuple will contain a value at position i in the range 0 to nValues[i].length-1.
        Parameters:
        nValues - the number of values used to form permutations
        Returns:
        an array containing all permutations obtained from the specified number of values
      • allPermutations

        default int[][] allPermutations​(int nValues)
        Builds an array containing all permutations that can be obtained from the specified number of values. All values are taken in the range 0 to nValues-1.
        Parameters:
        nValues - the number of values used to form permutations
        Returns:
        an array containing all permutations that can be obtained from the specified number of values
      • addInt

        default int[] addInt​(int[] t,
                             int value,
                             int index)
        Inserts the specified value in the specified array at the specified index. The new array is returned.
        Parameters:
        t - a 1-dimensional array of integers
        value - an integer to be inserted
        index - the index at which the value must be inserted
        Returns:
        an array obtained after the insertion of the specified value in the specified array at the specified index
      • addInt

        default int[] addInt​(int[] t,
                             int value)
        Appends the specified value to the specified array. The new array is returned.
        Parameters:
        t - a 1-dimensional array of integers
        value - an integer to be inserted
        Returns:
        an array obtained after appending the specified value to the specified array
      • contains

        default boolean contains​(int[] t,
                                 int v)
        Returns true iff the specified value is contained in the specified array
        Parameters:
        t - a 1-dimensional array of integers
        v - an integer
        Returns:
        true iff the specified value is contained in the specified array
      • sumOf

        default int sumOf​(int[] t)
        Returns the sum of the integers in the specified array.
        Parameters:
        t - a 1-dimensional array of integers
        Returns:
        the sum of the integers in the specified array
      • sumOf

        default int sumOf​(Range r)
        Returns the sum of the integers in the specified range.
        Parameters:
        r - a range
        Returns:
        the sum of the integers in the specified range
      • minOf

        default int minOf​(int[] t)
        Returns the minimum value in the specified array.
        Parameters:
        t - a 1-dimensional array of integers
        Returns:
        the minimum value in the specified array
      • maxOf

        default int maxOf​(int[] t)
        Returns the maximum value in the specified array.
        Parameters:
        t - a 1-dimensional array of integers
        Returns:
        the maximum value in the specified array
      • firstFrom

        default int firstFrom​(Range r,
                              FunctionalInterfaces.Intx1Predicate p)
        Returns the first value in the specified range that satisfies the specified predicate.
        Parameters:
        r - a range
        p - a predicate on integers
        Returns:
        the first value in the specified range that satisfies the specified predicate
      • firstFrom

        default int firstFrom​(Range r,
                              FunctionalInterfaces.Intx1Predicate p,
                              int defaultValue)
        Returns the first value in the specified range that satisfies the specified predicate, if one is found. Otherwise the specified default value is returned.
        Parameters:
        r - a range
        p - a predicate on integers
        defaultValue - an integer
        Returns:
        the first value in the specified range that satisfies the specified predicate, if any, or the specified default value otherwise