com.silentq.sort
Class BubbleSort

java.lang.Object
  |
  +--com.silentq.sort.BubbleSort

public class BubbleSort
extends java.lang.Object

BubbleSort is a popular sorting algorithm that bubbles through the list of items repeatedly, swapping any two adjacent items that are out of order. One iteration will leave the largest value at the end of the list, the second will leave the second largest in the right place, and so forth, swapping all adjacent pairs that are out of order along the way. This implementation is fairly standard.


Constructor Summary
BubbleSort()
           
 
Method Summary
static byte[] sort(byte[] values)
          Sorts an array of bytes in place, and returns the array.
static char[] sort(char[] values)
          Sorts an array of chars in place, and returns the array.
static double[] sort(double[] values)
          Sorts an array of doubles in place, and returns the array.
static float[] sort(float[] values)
          Sorts an array of floats in place, and returns the array.
static java.util.Vector sort(java.util.Hashtable values)
          Sorts a Hashtable based on the keys.
static int[] sort(int[] values)
          Sorts an array of ints in place, and returns the array.
static long[] sort(long[] values)
          Sorts an array of longs in place, and returns the array.
static short[] sort(short[] values)
          Sorts an array of shorts in place, and returns the array.
static java.lang.String[] sort(java.lang.String[] values)
          Sorts an array of Strings in place, and returns the array.
static java.util.Vector sort(java.util.Vector values)
          This is the actual bubblesort method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BubbleSort

public BubbleSort()
Method Detail

sort

public static int[] sort(int[] values)
Sorts an array of ints in place, and returns the array.
Parameters:
values - The int array.
Returns:
The sorted array.

sort

public static char[] sort(char[] values)
Sorts an array of chars in place, and returns the array.
Parameters:
values - The char array.
Returns:
The sorted array.

sort

public static byte[] sort(byte[] values)
Sorts an array of bytes in place, and returns the array.
Parameters:
values - The byte array.
Returns:
The sorted array.

sort

public static short[] sort(short[] values)
Sorts an array of shorts in place, and returns the array.
Parameters:
values - The short array.
Returns:
The sorted array.

sort

public static long[] sort(long[] values)
Sorts an array of longs in place, and returns the array.
Parameters:
values - The long array.
Returns:
The sorted array.

sort

public static float[] sort(float[] values)
Sorts an array of floats in place, and returns the array.
Parameters:
values - The float array.
Returns:
The sorted array.

sort

public static double[] sort(double[] values)
Sorts an array of doubles in place, and returns the array.
Parameters:
values - The double array.
Returns:
The sorted array.

sort

public static java.lang.String[] sort(java.lang.String[] values)
Sorts an array of Strings in place, and returns the array.
Parameters:
values - The String array.
Returns:
The sorted array.

sort

public static java.util.Vector sort(java.util.Hashtable values)
Sorts a Hashtable based on the keys.
Parameters:
values - The Hashtable.
Returns:
The sorted keys in a Vector.

sort

public static java.util.Vector sort(java.util.Vector values)
This is the actual bubblesort method. It sorts a Vector of objects, based on their type.
Parameters:
values - The Vector of values to sort.
Returns:
The sorted Vector.