public static int distanceP ( int index0 , int index1 , int size ) { int difference = index1 - index0 ; if ( difference < 0 ) { difference = size + difference ; } return difference ; }
Returns how many elements away in the positive direction you need to travel to get from index0 to index1 .