Permutation { public List<Integer> getOrbit(int element) { List<Integer> orbit = new ArrayList<Integer>(); orbit.add(element); int i = values[element]; while (i != element && orbit.size() < values.length) { orbit.add(i); i = values[i]; } return orbit; } 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 getOrbitTest() { Permutation p = new Permutation(4, 6, 1, 3, 2, 5, 0); List<Integer> orbit = p.getOrbit(1); Assert.assertEquals(5, orbit.size()); Assert.assertTrue(orbit.contains(1)); }