T - type of items held in the listK - type of the keys used to search the listL - type of the list containing the itemspublic abstract class SearchBase<T,K,L> extends Object
| Constructor and Description |
|---|
SearchBase() |
| Modifier and Type | Method and Description |
|---|---|
int |
binarySearch(L list,
K key)
Runs binary search for the entire list.
|
int |
binarySearch(L list,
K key,
int lower,
int upper)
Core implementation of the binary search.
|
SearchResult |
binarySearchResults(L list,
K key) |
protected abstract int |
compareTo(T item,
K key)
Compares the key to the item.
|
protected abstract int |
getCount(L list)
Gets the count of items in the list.
|
protected abstract T |
getValue(L list,
int index)
Used to access list values by index in the list.
|
public int binarySearch(L list, K key) throws IOException
list - list ordered in ascending key value.key - key to be found in the list.IOException - if there was a problem accessing data file.public int binarySearch(L list, K key, int lower, int upper) throws IOException
list - list ordered in ascending key valuekey - to be found in the listlower - start search from this index.upper - search up to and including this index.IOException - if there was a problem accessing data file.public SearchResult binarySearchResults(L list, K key) throws IOException
IOExceptionprotected abstract int getCount(L list)
list - whose is to be returnedprotected abstract T getValue(L list, int index) throws IOException
list - whose value is to be returnedindex - of the value to returnIOException - if there was a problem accessing data file.protected abstract int compareTo(T item, K key) throws IOException
item - to be compared against the key.key - to compare to the item.IOException - if there was a problem accessing data file.Copyright © 2017 51Degrees. All rights reserved.