Changeset 2731 for trunk/src/Locator.h


Ignore:
Timestamp:
01/16/13 16:45:43 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Redefined Locator and its derived classes as template class.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Locator.h

    r2730 r2731  
    1919 * @author TakeshiNakazato
    2020 */
    21 class Locator {
     21template <class T> class Locator {
    2222public:
    2323  // Default constructor.
     
    2929  // @param[in] copystorage whether allocate internal memory or not.
    3030  // @see set()
    31   Locator(double *v, unsigned int n, bool copystorage=true);
    32 
     31  Locator(T *v, unsigned int n, bool copystorage=true);
     32 
    3333  // Set data. The data must be sorted in either ascending or descending
    3434  // order, and must not have any duplicate elements.
     
    4242  // it will take a risk to allow to edit the data to be searched from
    4343  // outside the class.
    44   void set(double *v, unsigned int n, bool copystorage=true);
    45 
     44  void set(T *v, unsigned int n, bool copystorage=true);
     45 
    4646  // Destructor.
    4747  virtual ~Locator();
    48 
     48 
    4949  // Return right hand side index of location.
    5050  // @param[in] x input value to be located.
     
    5454  // case while x_[j-1] > x >= x_[j] for descending case.
    5555  // Returned value 0 or x.nelements() indicates out of range.
    56   virtual unsigned int locate(double x) = 0;
    57 
     56  virtual unsigned int locate(T x) = 0;
     57 
    5858protected:
    5959  // Bisection search.
     
    6161  // @param[in] left the leftmost index to search.
    6262  // @param[in] right the rightmost index to search.
    63   unsigned int bisection(double x, unsigned int left, unsigned int right);
     63  unsigned int bisection(T x, unsigned int left, unsigned int right);
    6464 
    65   // Hunt algorithm
    66   // @param[in] x input value to be located.
    67   // @param[in,out] left input: the starting point for hunt.
    68   //                     output: the left index of hunted region.
    69   // @param[out] right the right index of hunted region.
    70   void hunt(double x, unsigned int &left, unsigned int &right);
    71 
    7265  // Pointer to the data.
    73   double *x_;
     66  T *x_;
    7467
    7568  // Length of the data.
     
    8477
    8578}
     79
     80#include "Locator.tcc"
     81
    8682#endif
Note: See TracChangeset for help on using the changeset viewer.