|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpivot.collections.Sequence.Search
public static class Sequence.Search
Contains utility methods for searching sequences.
Constructor Summary | |
---|---|
Sequence.Search()
|
Method Summary | ||
---|---|---|
static
|
binarySearch(Sequence<T> sequence,
T item)
Performs a binary search of a sequence for the given comparable item. |
|
static
|
binarySearch(Sequence<T> sequence,
T item,
Comparator<T> comparator)
Performs a binary search of a sequence for the given item. |
|
static
|
linearSearch(Sequence<T> sequence,
T item)
Performs a linear search of a sequence for the given comparable item. |
|
static
|
linearSearch(Sequence<T> sequence,
T item,
Comparator<T> comparator)
Performs a linear search of a sequence for the given item. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Sequence.Search()
Method Detail |
---|
public static <T extends Comparable<? super T>> int binarySearch(Sequence<T> sequence, T item)
binarySearch(Sequence, Object, Comparator)
.
public static <T> int binarySearch(Sequence<T> sequence, T item, Comparator<T> comparator)
sequence
- The sequence to search. If the sequence is not sorted, the behavior
is undefined.item
- The item to search for.comparator
- Comparator that determines element order.
If the sequence contains multiple elements equal to the specified item, there is no guarantee which one will be found.
public static <T extends Comparable<? super T>> int linearSearch(Sequence<T> sequence, T item)
linearSearch(Sequence, Object, Comparator)
.
public static <T> int linearSearch(Sequence<T> sequence, T item, Comparator<T> comparator)
sequence
- The sequence to search.item
- The item to search for.comparator
- Comparator that will be used to determine logical equality.
If the sequence contains multiple elements equal to the specified item, this will return the first occurrence.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |