92085c3371de826e8b9a6438bdbf2fd5dd5ece00
[jalview.git] / src / jalview / util / ArrayUtils.java
1 package jalview.util;
2
3 public class ArrayUtils
4 {
5   /**
6    * Reverse the given array 'in situ'
7    * 
8    * @param arr
9    */
10   public static void reverseIntArray(int[] arr)
11   {
12     if (arr != null)
13     {
14       /*
15        * swap [k] with [end-k] up to the half way point in the array
16        * if length is odd, the middle entry is left untouched by the excitement
17        */
18       int last = arr.length - 1;
19       for (int k = 0; k < arr.length / 2; k++)
20       {
21         int temp = arr[k];
22         arr[k] = arr[last - k];
23         arr[last - k] = temp;
24       }
25     }
26   }
27 }