code: private static <T> void permuteArray(T[] arr, int cp) {
  		// Allow negative cp points for convenience.
  		if(cp == 0) {
  			return;
  		}
  		if(cp < 0) {
  			cp = arr.length+cp;
  		}
  		if(cp < 0 || cp >= arr.length) {
  			throw new ArrayIndexOutOfBoundsException(
  					"Permutation point ("+cp+") must be between -ca2.length and ca2.length-1" );
  		}
  
  		List<T> temp = new ArrayList<T>(cp);
  
  		// shift residues left
  		for(int i=0;i<cp;i++) {
  			temp.add(arr[i]);
  		}
  		for(int j=cp;j<arr.length;j++) {
  			arr[j-cp]=arr[j];
  		}
  		for(int i=0;i<cp;i++) {
  			arr[arr.length-cp+i] = temp.get(i);
  		}
  	}
docs: Circularly permutes arr in place.
  
  <p>Similar to {@link Collections#rotate(List, int)} but with reversed
  direction. Perhaps it would be more efficient to use the Collections version?
  @param <T>
  @param arr The array to be permuted
  @param cp The number of residues to shift leftward, or equivalently, the index of
  the first element after the permutation point.