|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--drasys.or.alg.BinarySearch
An implementation of a binary search. The compare object must be set to search for Objects.
References:
Introduction to Algorithms
Thomas H. Cormen, et al / Hardcover / Published 1990
Constructor Summary | |
BinarySearch()
The compare object is not set. |
|
BinarySearch(boolean descending)
If descending is true then the elements must be in high-to-low order. |
|
BinarySearch(boolean descending,
CompareI compare)
If descending is true then the elements must be in high-to-low order. |
|
BinarySearch(CompareI compare)
The compare object is set to 'compare'. |
Method Summary | |
int |
find(byte[] array,
byte key)
Returns the index of a matching element in the block. |
int |
find(byte[] array,
byte key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(double[] array,
double key)
Returns the index of a matching element in the block. |
int |
find(double[] array,
double key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(float[] array,
float key)
Returns the index of a matching element in the block. |
int |
find(float[] array,
float key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(int[] array,
int key)
Returns the index of a matching element in the block. |
int |
find(int[] array,
int key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(long[] array,
long key)
Returns the index of a matching element in the block. |
int |
find(long[] array,
long key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(java.lang.Object[] array,
java.lang.Object key)
Returns the index of a matching element in the block. |
int |
find(java.lang.Object[] array,
java.lang.Object key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(short[] array,
short key)
Returns the index of a matching element in the block. |
int |
find(short[] array,
short key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(java.lang.String[] array,
java.lang.String key)
Returns the index of a matching element in the block. |
int |
find(java.lang.String[] array,
java.lang.String key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(VectorI vector,
double key)
Returns the index of a matching element in the block. |
int |
find(VectorI vector,
double key,
int from,
int to)
Returns the index of a matching element in the block. |
int |
find(java.util.Vector vector,
java.lang.Object key)
Returns the index of a matching element in the block. |
int |
find(java.util.Vector vector,
java.lang.Object key,
int from,
int to)
Returns the index of a matching element in the block. |
CompareI |
getCompare()
Gets the compare object. |
int |
insertionIndex()
If a find fails, this returns the index where the new element should be inserted. |
void |
setAscending()
Sets order to ascending. |
void |
setCompare(CompareI compare)
Sets the compare object. |
void |
setDescending()
Sets order to descending. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public BinarySearch()
public BinarySearch(boolean descending)
public BinarySearch(CompareI compare)
public BinarySearch(boolean descending, CompareI compare)
Method Detail |
public void setCompare(CompareI compare)
public CompareI getCompare()
public void setDescending()
public void setAscending()
public int insertionIndex()
public int find(java.lang.Object[] array, java.lang.Object key)
public int find(java.lang.Object[] array, java.lang.Object key, int from, int to)
public int find(java.util.Vector vector, java.lang.Object key)
public int find(java.util.Vector vector, java.lang.Object key, int from, int to)
public int find(int[] array, int key)
public int find(int[] array, int key, int from, int to)
public int find(short[] array, short key)
public int find(short[] array, short key, int from, int to)
public int find(byte[] array, byte key)
public int find(byte[] array, byte key, int from, int to)
public int find(double[] array, double key)
public int find(double[] array, double key, int from, int to)
public int find(float[] array, float key)
public int find(float[] array, float key, int from, int to)
public int find(long[] array, long key)
public int find(long[] array, long key, int from, int to)
public int find(java.lang.String[] array, java.lang.String key)
public int find(java.lang.String[] array, java.lang.String key, int from, int to)
public int find(VectorI vector, double key)
public int find(VectorI vector, double key, int from, int to)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |