|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface SearchingGopher
Generic adapter to present array-like structures to instances of
SearchingAlgorithm for searching.
These adapters allow us to use generic array-searching algorithms on a variety of structures, including disk-based ones, without substantial additional memory overhead. It does assume a data model that allows fast random-access reads, so it is inappropriate for linked lists, variable-length record data files, etc. It is extremely effective at searching fixed-length records and indexes, and makes the comparison an implementation detail that can be optimized internally (e.g. byte comparisons rather instantiating Strings).
It uses an abstract memory register to store values for comparison later. This means that a SearchingGopher must store some kind of state to do the comparison, in addition to any state required to access the underlying data. Since most algorithms collect and repeatedly compare against a minimum or maximum key value, this allows a single read to store the key value, instead of re-reading the item each time a comparison is called for.
Copyright 2003-2006 Partner Software, Inc.
| Method Summary | |
|---|---|
int |
compare(int index)
Compares the key of the item at the given index with the current remembered key. |
void |
remember(java.lang.Object key)
Remembers the given value for future comparisons. |
int |
size()
Returns the number of items in the array. |
| Method Detail |
|---|
void remember(java.lang.Object key)
key - key value to rememberint compare(int index)
index - index of key value to compare to remembered key value
int size()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||