Class IntUtils


  • public final class IntUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] clone​(int[] array)
      Return a clone of the given int array.
      static boolean equals​(int[] left, int[] right)
      Compare two int arrays.
      static void fill​(int[] array, int value)
      Fill the given int array with the given value.
      static void quicksort​(int[] source)
      Sorts this array of integers according to the Quicksort algorithm.
      static void quicksort​(int[] source, int left, int right)
      Sort a subarray of a source array.
      static int[] subArray​(int[] input, int start, int end)
      Generates a subarray of a given int array.
      static java.lang.String toHexString​(int[] input)  
      static java.lang.String toString​(int[] input)  
      • Methods inherited from class java.lang.Object

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

      • equals

        public static boolean equals​(int[] left,
                                     int[] right)
        Compare two int arrays. No null checks are performed.
        Parameters:
        left - the first int array
        right - the second int array
        Returns:
        the result of the comparison
      • clone

        public static int[] clone​(int[] array)
        Return a clone of the given int array. No null checks are performed.
        Parameters:
        array - the array to clone
        Returns:
        the clone of the given array
      • fill

        public static void fill​(int[] array,
                                int value)
        Fill the given int array with the given value.
        Parameters:
        array - the array
        value - the value
      • quicksort

        public static void quicksort​(int[] source)
        Sorts this array of integers according to the Quicksort algorithm. After calling this method this array is sorted in ascending order with the smallest integer taking position 0 in the array.

        This implementation is based on the quicksort algorithm as described in Data Structures In Java by Thomas A. Standish, Chapter 10, ISBN 0-201-30564-X.

        Parameters:
        source - the array of integers that needs to be sorted.
      • quicksort

        public static void quicksort​(int[] source,
                                     int left,
                                     int right)
        Sort a subarray of a source array. The subarray is specified by its start and end index.
        Parameters:
        source - the int array to be sorted
        left - the start index of the subarray
        right - the end index of the subarray
      • subArray

        public static int[] subArray​(int[] input,
                                     int start,
                                     int end)
        Generates a subarray of a given int array.
        Parameters:
        input - - the input int array
        start - - the start index
        end - - the end index
        Returns:
        a subarray of input, ranging from start to end
      • toString

        public static java.lang.String toString​(int[] input)
        Parameters:
        input - an int array
        Returns:
        a human readable form of the given int array
      • toHexString

        public static java.lang.String toHexString​(int[] input)
        Parameters:
        input - an int arary
        Returns:
        the int array as hex string