|
Algorithm Development Kit 1.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectalgs.model.array.Selection
public class Selection
Helper class to locate selected values from an Array of Comparable.
| Constructor Summary | |
|---|---|
Selection()
|
|
| Method Summary | |
|---|---|
static java.lang.Comparable |
max(java.lang.Comparable[] ar)
Locate the maximum value from an array of Comparables. |
static java.lang.Comparable |
min(java.lang.Comparable[] ar)
Locate the minimum value from an array of Comparable objects. |
static int |
partition(java.lang.Comparable[] ar,
int left,
int right,
int pivotIndex)
In linear time, group an array into two parts, those less than a certain value (left), and those greater than or equal to a certain value (right). |
static int |
partition(java.lang.Object[] ar,
int left,
int right,
int pivotIndex,
java.util.Comparator comparator)
In linear time, group an array into two parts, those less than a certain value (left), and those greater than or equal to a certain value (right). |
static boolean |
qsort(java.lang.Comparable[] ar,
int left,
int right)
Sort using Quicksort method. |
static boolean |
qsort(java.lang.Object[] ar,
int left,
int right,
java.util.Comparator comparator)
Sort using Quicksort method. |
static java.lang.Comparable |
select(java.lang.Comparable[] ar,
int k,
int left,
int right)
Select the kth value in an array (1 ≤ k ≤ right-left+1) through recursive partitioning. |
static java.lang.Object |
select(java.lang.Object[] ar,
int k,
int left,
int right,
java.util.Comparator comparator)
Select the kth value in an array (1 ≤ k ≤ right-left+1) through recursive partitioning. |
static int |
selectPivotIndex(java.lang.Comparable[] ar,
int left,
int right)
Select an appropriate pivot within the [left, right] range. |
static int |
selectPivotIndex(java.lang.Object[] ar,
int left,
int right,
java.util.Comparator comparator)
Select an appropriate pivot within the [left, right] range. |
static void |
swap(java.lang.Object[] ar,
int pos1,
int pos2)
Swap the two locations. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Selection()
| Method Detail |
|---|
public static void swap(java.lang.Object[] ar,
int pos1,
int pos2)
Does nothing if pos1 == pos2
ar - An array of objectspos1 - position of first element to swappos2 - position of second element to swap
java.lang.NullPointerException - if ar is null
java.lang.ArrayIndexOutOfBoundsException - if either pos1 or pos2 is invalidpublic static java.lang.Comparable min(java.lang.Comparable[] ar)
Comparable objects.
ar - An array of Comparable objects
java.lang.NullPointerException - if ar is null
java.lang.ArrayIndexOutOfBoundsException - if ar is an empty arraypublic static java.lang.Comparable max(java.lang.Comparable[] ar)
ar - An array of Comparable objects
java.lang.NullPointerException - if ar is null or references an empty array.
public static int partition(java.lang.Comparable[] ar,
int left,
int right,
int pivotIndex)
ar - An array of Comparable objectsleft - lower bound index positionright - upper bound index positionpivotIndex - index around which the partition is being made.
public static int partition(java.lang.Object[] ar,
int left,
int right,
int pivotIndex,
java.util.Comparator comparator)
ar - An array of Comparable objectsleft - lower bound index position (0 ≤ left < ar.length)right - upper bound index position (0 ≤ left < ar.length)pivotIndex - index around which the partition is being made.comparator - Externalize the comparison of two objects into this method.
public static int selectPivotIndex(java.lang.Comparable[] ar,
int left,
int right)
ar - Array of Comparable objectsleft - The left-bounds within which to search (0 ≤ left < ar.length)right - The right-bounds within which to search (0 ≤ right < ar.length)
public static int selectPivotIndex(java.lang.Object[] ar,
int left,
int right,
java.util.Comparator comparator)
ar - Array of Comparable objectsleft - The left-bounds within which to search (0 ≤ left < ar.length)right - The right-bounds within which to search (0 ≤ right < ar.length)comparator - Externalize the comparison of two objects into this method.
public static java.lang.Comparable select(java.lang.Comparable[] ar,
int k,
int left,
int right)
ar - Array of Comparable objectsk - The position in sorted order of the desired location (1 ≤ k ≤ right-left+1)left - The left-bounds within which to search (0 ≤ left < ar.length)right - The right-bounds within which to search (0 ≤ right < ar.length)
public static java.lang.Object select(java.lang.Object[] ar,
int k,
int left,
int right,
java.util.Comparator comparator)
ar - Array of objectsk - The position in sorted order of the desired location (1 ≤ k ≤ right-left+1)left - The left-bounds within which to search (0 ≤ left < ar.length)right - The right-bounds within which to search (0 ≤ right < ar.length)comparator - Externalize the comparison of two objects into this method.
public static boolean qsort(java.lang.Comparable[] ar,
int left,
int right)
ar - Array of Comparable objectsleft - The left-bounds within which to sort (0 ≤ left < ar.length)right - The right-bounds within which to sort (0 ≤ right < ar.length)
public static boolean qsort(java.lang.Object[] ar,
int left,
int right,
java.util.Comparator comparator)
ar - Array of Comparable objectsleft - The left-bounds within which to sort (0 ≤ left < ar.length)right - The right-bounds within which to sort (0 ≤ right < ar.length)comparator - Externalize the comparison of two objects into this method.
|
Algorithm Development Kit 1.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||