Partition { public Permutation setAsPermutation(int upTo) { int[] p = new int[upTo]; for (int i = 0; i < upTo; i++) { p[i] = this.cells.get(i).first(); } return new Permutation(p); } Partition();  Partition(Partition other);  Partition(int[][] cellData); static Partition unit(int size); @Override boolean equals(Object o); @Override int hashCode(); int size(); int numberOfElements(); boolean isDiscrete(); Permutation toPermutation(); boolean inOrder(); int getFirstInCell(int cellIndex); SortedSet<Integer> getCell(int cellIndex); Partition splitBefore(int cellIndex, int splitElement); Partition splitAfter(int cellIndex, int splitElement); Permutation setAsPermutation(int upTo); boolean isDiscreteCell(int cellIndex); int getIndexOfFirstNonDiscreteCell(); void addSingletonCell(int element); void removeCell(int index); void addCell(int... elements); void addCell(Collection<Integer> elements); void addToCell(int index, int element); void insertCell(int index, SortedSet<Integer> cell); SortedSet<Integer> copyBlock(int cellIndex); void order(); boolean inSameCell(int elementI, int elementJ); @Override String toString(); static Partition fromString(String strForm);  }
@Test public void setAsPermutationTest() { int partitionSize = 5; int permutationSize = 3; Partition partition = new Partition(); for (int i = 0; i < partitionSize; i++) { partition.addSingletonCell(i); } Permutation permutation = partition.setAsPermutation(permutationSize); for (int i = 0; i < permutationSize; i++) { Assert.assertEquals(i, permutation.get(i)); } }