|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.util.BinarySearch
public class BinarySearch
Contains methods for searching arrays.
Comparable
Field Summary | |
---|---|
static int |
SERIES
Class revision number. |
Constructor Summary | |
---|---|
BinarySearch()
|
Method Summary | |
---|---|
static int |
find(java.lang.Object[] tbl,
Comparable key)
Searches array tbl looking for an element of the array that compares equal to key using a binary search algorithm. |
static int |
find(java.lang.Object[] tbl,
java.lang.Object key,
Comparable comp)
Searches array tbl looking for an element of the array that compares equal to key using a binary search algorithm. |
static void |
main(java.lang.String[] argv)
Test driver. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SERIES
Constructor Detail |
---|
public BinarySearch()
Method Detail |
---|
public static int find(java.lang.Object[] tbl, java.lang.Object key, Comparable comp)
This algorithm always finds the first matching element in the array (if there is one) even if there are multiple matches.
The compare() method of comp is always called with key as its first argument, and an element of tbl as its second argument.
tbl
- The array to be searched.key
- The key value of the element to locate within the array.comp
- Contains the comparison method with which to compare the key to the
array elements during the search.
public static int find(java.lang.Object[] tbl, Comparable key)
The key is an object that implements the Comparable
interface.
Each iteration through the search involves comparing the key to an element
in the array, using the key's compareTo() method.
This algorithm always finds the first matching element in the array (if there is one) even if there are multiple matches.
tbl
- The array to be searched.key
- The key value of the element to locate within the array.
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |