com.partnersoft.data
Class ArrayLinearSearch

java.lang.Object
  extended by com.partnersoft.data.ArrayLinearSearch
All Implemented Interfaces:
ArraySearchingAlgorithm

public class ArrayLinearSearch
extends java.lang.Object
implements ArraySearchingAlgorithm

A generic full-scan search. Slow; avoid if you can.

Author:
Paul Reavis Copyright 2004 Partner Software, Inc.

Constructor Summary
ArrayLinearSearch()
           
 
Method Summary
 int findClosest(ArraySearchingGopher gopher, java.lang.Object key)
          Just do it.
 int findClosest(ArraySearchingGopher gopher, java.lang.Object key, int start, int end)
          Finds the slot where the given key _would_ go if it were in there.
 int search(ArraySearchingGopher gopher, java.lang.Object key)
          Just do it.
 int search(ArraySearchingGopher gopher, java.lang.Object key, int start, int end)
          Does the job using the given gopher over the given range.
static ArrayLinearSearch singleton()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayLinearSearch

public ArrayLinearSearch()
Method Detail

singleton

public static ArrayLinearSearch singleton()

search

public final int search(ArraySearchingGopher gopher,
                        java.lang.Object key)
Just do it.

Specified by:
search in interface ArraySearchingAlgorithm

search

public final int search(ArraySearchingGopher gopher,
                        java.lang.Object key,
                        int start,
                        int end)
Description copied from interface: ArraySearchingAlgorithm
Does the job using the given gopher over the given range. Returns -1 if key not found.

Specified by:
search in interface ArraySearchingAlgorithm

findClosest

public final int findClosest(ArraySearchingGopher gopher,
                             java.lang.Object key)
Just do it.

Specified by:
findClosest in interface ArraySearchingAlgorithm

findClosest

public final int findClosest(ArraySearchingGopher gopher,
                             java.lang.Object key,
                             int start,
                             int end)
Description copied from interface: ArraySearchingAlgorithm
Finds the slot where the given key _would_ go if it were in there. Always returns something.

Specified by:
findClosest in interface ArraySearchingAlgorithm