|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.data.BinarySearch
public class BinarySearch
A generic binary search algorithm.
This search method requires that keys be presorted in order; however it is very fast and reliable.
This isn't declared as a singleton, since it has no actual overhead (no
state), so there's not strong reason to limit instantiation. However an
standardInstance() method is provided that provides a shared
instance.
You can also just use this via the handy convenience method
SearchingLib.binarySearch(SearchingGopher, Object); that is actually
the recommended method.
Copyright 2000-2006 Partner Software, Inc.
| Constructor Summary | |
|---|---|
BinarySearch()
Creates a new BinarySearch algorithm object. |
|
| Method Summary | |
|---|---|
int |
findClosest(SearchingGopher gopher,
java.lang.Object key)
Finds the slot where the given key would go if it were in there. |
int |
findClosest(SearchingGopher gopher,
java.lang.Object key,
int start,
int end)
Finds the slot where the given key would go if it were in there over the given inclusive range (start <= i <= end). |
int |
search(SearchingGopher gopher,
java.lang.Object key)
Searches for the given key using the given gopher. |
int |
search(SearchingGopher gopher,
java.lang.Object key,
int start,
int end)
Searches for the given key using the given gopher over the given range (start <= i < end). |
static BinarySearch |
standardInstance()
Returns a singleton shared instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BinarySearch()
standardInstance() method.
| Method Detail |
|---|
public static BinarySearch standardInstance()
public int search(SearchingGopher gopher,
java.lang.Object key)
SearchingAlgorithm
search in interface SearchingAlgorithmgopher - adapter to underlying array-like structurekey - value to search for
public int search(SearchingGopher gopher,
java.lang.Object key,
int start,
int end)
SearchingAlgorithm
search in interface SearchingAlgorithmgopher - adapter to underlying array-like structurekey - value to search forstart - start of index range, inclusive (start <= i)end - end of index range, exclusive (i < end)
public int findClosest(SearchingGopher gopher,
java.lang.Object key)
SearchingAlgorithm
findClosest in interface SearchingAlgorithmgopher - adapter to underlying array-like structurekey - value to search for
public int findClosest(SearchingGopher gopher,
java.lang.Object key,
int start,
int end)
SearchingAlgorithm
findClosest in interface SearchingAlgorithmgopher - adapter to underlying array-like structurekey - value to search forstart - start of index range, inclusive (start <= i)end - end of index range, exclusive (i < end)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||