org.onebusaway.transit_data_federation.impl.time
Class GenericBinarySearch
java.lang.Object
org.onebusaway.transit_data_federation.impl.time.GenericBinarySearch
public class GenericBinarySearch
- extends Object
Generic binary search that can accepts lists of Java objects that can be
adapted to a double value for searching.
- Author:
- bdferris
Method Summary |
static
|
search(List<T> elements,
double targetValue,
GenericBinarySearch.ValueAdapter<T> valueAdapter)
Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.ValueAdapter |
static
|
search(T elements,
int size,
double targetValue,
GenericBinarySearch.IndexAdapter<T> valueAdapter)
Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.ValueAdapter |
static
|
searchRange(T elements,
int indexFrom,
int indexTo,
double targetValue,
GenericBinarySearch.IndexAdapter<T> valueAdapter)
Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.IndexAdapter |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericBinarySearch
public GenericBinarySearch()
search
public static <T> int search(List<T> elements,
double targetValue,
GenericBinarySearch.ValueAdapter<T> valueAdapter)
- Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.ValueAdapter
- Parameters:
elements
- a list of objects, sorted in the order appropriate to the
GenericBinarySearch.ValueAdapter
targetValue
- target value to search forvalueAdapter
- adapter to convert the input element type into a double
value
- Returns:
search
public static <T> int search(T elements,
int size,
double targetValue,
GenericBinarySearch.IndexAdapter<T> valueAdapter)
- Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.ValueAdapter
- Parameters:
elements
- a list of objects, sorted in the order appropriate to the
GenericBinarySearch.ValueAdapter
targetValue
- target value to search forvalueAdapter
- adapter to convert the input element type into a double
value
- Returns:
searchRange
public static <T> int searchRange(T elements,
int indexFrom,
int indexTo,
double targetValue,
GenericBinarySearch.IndexAdapter<T> valueAdapter)
- Return an index into the element list such that if a new element with the
specified target value was inserted into the list at the specified index,
the list would remain in sorted order with respect to the
GenericBinarySearch.IndexAdapter
- Parameters:
elements
- a collection of objects, sorted in the order appropriate to
the GenericBinarySearch.IndexAdapter
indexFrom
- starting index rangeindexTo
- ending index rangetargetValue
- target value to search forvalueAdapter
- adapter to convert the input element type into a double
value
- Returns:
Copyright © 2012 OneBusAway. All Rights Reserved.