Class ArrayUtil

java.lang.Object
org.jgrapht.util.ArrayUtil

public class ArrayUtil extends Object
Utility class to simplify handling of arrays.
Author:
Hannes Wellmann
  • Method Summary

    Modifier and Type
    Method
    Description
    static final void
    reverse(int[] arr, int from, int to)
    Reverses the order of the elements in the specified range within the given array.
    static final <V> void
    reverse(V[] arr, int from, int to)
    Reverses the order of the elements in the specified range within the given array.
    static final <V> void
    swap(V[] arr, int i, int j)
    Swaps the two elements at the specified indices in the given array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • reverse

      public static final <V> void reverse(V[] arr, int from, int to)
      Reverses the order of the elements in the specified range within the given array.
      Type Parameters:
      V - the type of elements in the array
      Parameters:
      arr - the array
      from - the index of the first element (inclusive) inside the range to reverse
      to - the index of the last element (inclusive) inside the range to reverse
    • reverse

      public static final void reverse(int[] arr, int from, int to)
      Reverses the order of the elements in the specified range within the given array.
      Parameters:
      arr - the array
      from - the index of the first element (inclusive) inside the range to reverse
      to - the index of the last element (inclusive) inside the range to reverse
    • swap

      public static final <V> void swap(V[] arr, int i, int j)
      Swaps the two elements at the specified indices in the given array.
      Type Parameters:
      V - the type of elements in the array
      Parameters:
      arr - the array
      i - the index of the first element
      j - the index of the second element