Class ArrayUtilities

java.lang.Object
  extended by ArrayUtilities

public class ArrayUtilities
extends java.lang.Object

A suite of utility methods for arrays

Version:
July 2005
Author:
Todd A. Whittaker

Constructor Summary
ArrayUtilities()
           
 
Method Summary
static int[] createRandomIntArray(int length)
          Creates an array of random integer data.
static int[] createSortedIntArray(int length)
          Creates an array of integer data in sorted order.
static int[] shuffleArray(int[] arr)
          Randomly rearranges the elements in the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtilities

public ArrayUtilities()
Method Detail

createRandomIntArray

public static int[] createRandomIntArray(int length)
Creates an array of random integer data. All numbers in the sequence are unique, and the minimum distance between numbers is 2, while the maximum distance is 102.

Parameters:
length - the length of the array to create
Returns:
the generated array

createSortedIntArray

public static int[] createSortedIntArray(int length)
Creates an array of integer data in sorted order. In particular it creates an increasing sequence of numbers that are between 2 and 102 apart.

Parameters:
length - the length of the array to create
Returns:
the generated array

shuffleArray

public static int[] shuffleArray(int[] arr)
Randomly rearranges the elements in the specified array.

Parameters:
arr - the array to shuffle
Returns:
the array randomly shuffled