Java Array Find findAllArgumentPermutations(Object[][] allArguments)

Here you can find the source of findAllArgumentPermutations(Object[][] allArguments)

Description

Permute all possible parameters

License

Apache License

Parameter

Parameter Description
caller a parameter
method a parameter
allArguments a parameter
offset a parameter
arguments a parameter

Declaration

public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright Searchbox - http://www.searchbox.com
 * /*from w  ww . j av a2s.co  m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Permute all possible parameters
     * 
     * @param caller
     * @param method
     * @param allArguments
     * @param offset
     * @param arguments
     */
    public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments) {
        return findAllArgumentPermutations(allArguments, 0, 0, new Object[allArguments.length],
                new ArrayList<Object[]>());

    }

    public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments, int depth, int offset,
            Object[] arguments, List<Object[]> results) {
        if (depth < allArguments.length) {
            for (int i = offset; i < allArguments[depth].length; i++) {
                arguments[depth] = allArguments[depth][i];
                // we got a bag here...
                if ((depth + 1) == arguments.length) {
                    results.add(arguments.clone());
                }
                findAllArgumentPermutations(allArguments, depth + 1, offset, arguments, results);
            }
        }
        return results;
    }
}

Related

  1. findAll(int[] arr1, int[] arr2)
  2. findAllOrientations(int[][] matrix)
  3. getIndex(double income, String[] scopes)
  4. getIndex(String[] array, String value)
  5. getIndexObject(Object[] data, Object object)