I need to create method that will return permutations of arraylist. I used this method but it returns List<List<T>>
and i need to get Set<Set<T>>
type. Can anyone help me achieve this?
EDIT: I have tried:
public Set<Set<T>> permute() {
List<List<T>> tmp = generatePerm(this);
Set<Set<T>> tmpSet = new HashSet<>();
for (List<T> el : tmp){
tmpSet.add(new HashSet<T>(el));
}
return tmpSet;
}
But it only returns one permutation.
SOLUTION:
Okay i got it. This method is in class that extends ArrayList
so i simply implemented Set<T>
to this class and changed return type of this method to XList<Set<T>>
and it worked.