Package util

Class Arrays

java.lang.Object
util.Arrays

public class Arrays extends Object
Class for some extended array utility functions.

In contrast to java.util.Arrays, which provides functions for sorting arrays with a compareTo function that takes one argument, the function in this class uses a compareTo function with two arguments. The second argument can be used to modify the behavior of the comparison function. The sorting algorithm is a modified quicksort, which switches to insertion sort once the array sections to be sorted are small enough.

Since:
2002.04.02
  • Constructor Details

    • Arrays

      public Arrays()
      Create an arrays object (dummy).
      Since:
      2023.07.26 (Christian Borgelt)
  • Method Details

    • sort

      public static void sort(Arrays.CompareTo2[] array, int from, int to, Object data)
      Sort an arbitrary array.
      Parameters:
      array - the array to sort
      from - the start index of the section to sort
      to - the end index of the section to sort (exclusive)
      data - the additional data for the the comparisons
      Since:
      2002.04.02 (Christian Borgelt)
    • sort

      public static void sort(Arrays.CompareTo2[] array, Object data)
      Sort an arbitrary array.
      Parameters:
      array - the array to sort
      data - the additional data for the the comparisons
      Since:
      2002.04.02 (Christian Borgelt)