algs.model.search
Class SequentialSearch<T>
java.lang.Object
algs.model.search.SequentialSearch<T>
- Type Parameters:
T
- elements of the collection being searched are of this type.
public class SequentialSearch<T>
- extends java.lang.Object
Sequential Search in Java (both for indexed collections as well as
collections accessed via iterators).
- Since:
- 1.0
- Version:
- 1.0, 6/15/08
- Author:
- George Heineman
Method Summary |
boolean |
sequentialSearch(java.lang.Iterable<T> collection,
T t)
Apply the brute-force Sequential Search algorithm to search the
iterable collection (of type T) for the given target item. |
boolean |
sequentialSearch(T[] collection,
T t)
Apply the brute-force Sequential Search algorithm to search the
indexed collection (of type T) for the given target item. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SequentialSearch
public SequentialSearch()
sequentialSearch
public boolean sequentialSearch(T[] collection,
T t)
- Apply the brute-force Sequential Search algorithm to search the
indexed collection (of type T) for the given target item.
- Parameters:
collection
- indexed collection of type T being searchedt
- non-null target item to locate.
- Returns:
true
if target item exists within the collection;
false
otherwise.
sequentialSearch
public boolean sequentialSearch(java.lang.Iterable<T> collection,
T t)
- Apply the brute-force Sequential Search algorithm to search the
iterable collection (of type T) for the given target item.
- Parameters:
collection
- iterable collection of type T being searchedt
- non-null target item to locate
- Returns:
true
if target item exists within the collection;
false
otherwise.
This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.