Changeset 2731 for trunk/src/Locator.h
- Timestamp:
- 01/16/13 16:45:43 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Locator.h
r2730 r2731 19 19 * @author TakeshiNakazato 20 20 */ 21 class Locator {21 template <class T> class Locator { 22 22 public: 23 23 // Default constructor. … … 29 29 // @param[in] copystorage whether allocate internal memory or not. 30 30 // @see set() 31 Locator( double*v, unsigned int n, bool copystorage=true);32 31 Locator(T *v, unsigned int n, bool copystorage=true); 32 33 33 // Set data. The data must be sorted in either ascending or descending 34 34 // order, and must not have any duplicate elements. … … 42 42 // it will take a risk to allow to edit the data to be searched from 43 43 // 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 46 46 // Destructor. 47 47 virtual ~Locator(); 48 48 49 49 // Return right hand side index of location. 50 50 // @param[in] x input value to be located. … … 54 54 // case while x_[j-1] > x >= x_[j] for descending case. 55 55 // Returned value 0 or x.nelements() indicates out of range. 56 virtual unsigned int locate( doublex) = 0;57 56 virtual unsigned int locate(T x) = 0; 57 58 58 protected: 59 59 // Bisection search. … … 61 61 // @param[in] left the leftmost index to search. 62 62 // @param[in] right the rightmost index to search. 63 unsigned int bisection( doublex, unsigned int left, unsigned int right);63 unsigned int bisection(T x, unsigned int left, unsigned int right); 64 64 65 // Hunt algorithm66 // @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 72 65 // Pointer to the data. 73 double*x_;66 T *x_; 74 67 75 68 // Length of the data. … … 84 77 85 78 } 79 80 #include "Locator.tcc" 81 86 82 #endif
Note: See TracChangeset
for help on using the changeset viewer.