com.partnersoft.data
Class ArrayBinarySearch

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

public class ArrayBinarySearch
extends java.lang.Object
implements ArraySearchingAlgorithm

A generic binary search.

Author:
Paul Reavis Copyright 2000 Partner Software, Inc.

Constructor Summary
ArrayBinarySearch()
           
 
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 ArrayBinarySearch singleton()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayBinarySearch

public ArrayBinarySearch()
Method Detail

singleton

public static ArrayBinarySearch 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