Java List Permutate permuteList(List list, int[] permutations)

Here you can find the source of permuteList(List list, int[] permutations)

Description

permute List

License

Open Source License

Declaration

@SuppressWarnings({ "rawtypes", "unchecked" })
    public static void permuteList(List list, int[] permutations) 

Method Source Code


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

import java.util.ArrayList;
import java.util.List;

public class Main {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static void permuteList(List list, int[] permutations) {
        if (permutations.length != list.size()) {
            throw new IllegalArgumentException("List length and permutation length are not equal");
        }/*w ww  .  j  a  va  2s.  c om*/
        List<Object> tmpList = new ArrayList<Object>(permutations.length);
        for (int i = 0; i < permutations.length; i++) {
            tmpList.add(list.get(permutations[i]));
        }
        list.clear();
        list.addAll(tmpList);
    }
}

Related

  1. permute(List arr)
  2. permute(List list1)
  3. permute(List list, int index, List> result)
  4. permute(T[] arr, List p)
  5. permutedGroups(List> elementLists)
  6. permuteList(List in, int seed)
  7. permuteList(List list, Integer[] permutation)
  8. permVisit(int[] value, int n, int k, List res)