public abstract class BinarySearch<E>
extends java.lang.Object
Constructor and Description |
---|
BinarySearch() |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
compare(int index,
E element)
Compares element at
index position with given object. |
int |
find(E element)
Finds index of given element or negative value if element is not found.
|
int |
find(E element,
int low,
int high)
Finds index of given element in inclusive index range.
|
int |
findFirst(E o)
Finds very first index of given element or negative value if element is not found.
|
int |
findFirst(E o,
int low,
int high)
Finds very first index of given element in inclusive index range.
|
int |
findLast(E o)
Finds very last index of given element or negative value if element is not found.
|
int |
findLast(E o,
int low,
int high)
Finds very last index of given element in inclusive index range.
|
static <T extends java.lang.Comparable> |
forArray(T[] array)
Creates binary search wrapper over an array.
|
static <T> BinarySearch<T> |
forArray(T[] array,
java.util.Comparator<T> comparator)
Creates binary search wrapper over an array with given comparator.
|
static <T extends java.lang.Comparable> |
forList(java.util.List<T> list)
Creates binary search wrapper over a list of comparable elements.
|
static <T> BinarySearch<T> |
forList(java.util.List<T> list,
java.util.Comparator<T> comparator)
Creates binary search wrapper over a list with given comparator.
|
protected abstract int |
getLastIndex()
Returns index of last element in wrapped collection.
|
public static <T extends java.lang.Comparable> BinarySearch<T> forList(java.util.List<T> list)
public static <T> BinarySearch<T> forList(java.util.List<T> list, java.util.Comparator<T> comparator)
public static <T extends java.lang.Comparable> BinarySearch<T> forArray(T[] array)
public static <T> BinarySearch<T> forArray(T[] array, java.util.Comparator<T> comparator)
protected abstract int compare(int index, E element)
index
position with given object.protected abstract int getLastIndex()
public int find(E element)
public int find(E element, int low, int high)
public int findFirst(E o)
public int findFirst(E o, int low, int high)
public int findLast(E o)
public int findLast(E o, int low, int high)
Copyright © 2003-present Jodd Team