Permutation { public Permutation invert() { Permutation inversion = new Permutation(values.length); for (int i = 0; i < values.length; i++) { inversion.values[this.values[i]] = i; } return inversion; } Permutation(int size);  Permutation(int... values);  Permutation(Permutation other); @Override boolean equals(Object other); @Override int hashCode(); boolean isIdentity(); int size(); int get(int index); int[] getValues(); int firstIndexOfDifference(Permutation other); List<Integer> getOrbit(int element); void set(int index, int value); void setTo(Permutation other); Permutation multiply(Permutation other); Permutation invert(); String toCycleString(); @Override String toString();  }
@Test public void invertTest() { int[] values = new int[]{3, 1, 0, 2}; int[] invert = new int[]{2, 1, 3, 0}; Permutation p = new Permutation(values); Permutation invP = new Permutation(invert); Assert.assertEquals(invP, p.invert()); }