Java Array Permute permute(int[] in, int[] idx)

Here you can find the source of permute(int[] in, int[] idx)

Description

permute

License

Apache License

Declaration

public static final int[] permute(int[] in, int[] idx) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static final int[] permute(int[] in, int[] idx) {
        int[] out = new int[in.length];
        for (int i = 0; i < in.length; i++)
            out[i] = in[idx[i]];//from   w w  w .  ja v a 2s. c  o m

        return out;
    }

    public static final float[] permute(float[] in, int[] idx) {
        float[] out = new float[in.length];
        for (int i = 0; i < in.length; i++)
            out[i] = in[idx[i]];

        return out;
    }

    public static final double[] permute(double[] in, int[] idx) {
        double[] out = new double[in.length];
        for (int i = 0; i < in.length; i++)
            out[i] = in[idx[i]];

        return out;
    }
}

Related

  1. permutation(final int start, final int end)
  2. permutation(int n)
  3. permute(int k, Object[] os)
  4. permute(int[] elements, int i, int j)
  5. permute(int[] p, Object[] data, boolean clone)
  6. permute(String str, int startIndex, int endIndex)
  7. permute(T[] array)
  8. permute(T[] values)