Last change
on this file since 2870 was 2731, checked in by Takeshi Nakazato, 12 years ago |
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 size:
1.4 KB
|
Rev | Line | |
---|
[2727] | 1 | //
|
---|
| 2 | // C++ Interface: HuntLocator
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | //
|
---|
| 7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2012
|
---|
| 8 | //
|
---|
| 9 | // Copyright: See COPYING file that comes with this distribution
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | #ifndef ASAP_HUNT_LOCATOR_H
|
---|
| 13 | #define ASAP_HUNT_LOCATOR_H
|
---|
| 14 |
|
---|
| 15 | #include "Locator.h"
|
---|
| 16 |
|
---|
| 17 | namespace asap {
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * Implementation of locate operation by bisection search
|
---|
| 21 | * @author TakeshiNakazato
|
---|
| 22 | */
|
---|
[2731] | 23 | template <class T> class HuntLocator : public Locator<T> {
|
---|
[2727] | 24 | public:
|
---|
[2730] | 25 | // Default constructor.
|
---|
| 26 | HuntLocator();
|
---|
[2727] | 27 |
|
---|
[2730] | 28 | // Construct with data
|
---|
| 29 | // @param[in] v pointer to input data.
|
---|
| 30 | // @param[in] n length of the data.
|
---|
| 31 | // @param[in] copystorage whether allocate internal memory or not.
|
---|
| 32 | // @see Locator::set()
|
---|
[2731] | 33 | HuntLocator(T *v, unsigned int n, bool copystorage=true);
|
---|
[2730] | 34 |
|
---|
| 35 | // Destructor.
|
---|
[2727] | 36 | virtual ~HuntLocator();
|
---|
| 37 |
|
---|
[2730] | 38 | // Return right hand side index of location using bisection search
|
---|
| 39 | // plus hunt algorithm.
|
---|
| 40 | // @param[in] x input value to be located.
|
---|
| 41 | // @return location as an index j.
|
---|
| 42 | // @see Locator::locate()
|
---|
[2731] | 43 | unsigned int locate(T x);
|
---|
[2727] | 44 | private:
|
---|
[2731] | 45 | // Hunt algorithm
|
---|
| 46 | // @param[in] x input value to be located.
|
---|
| 47 | // @param[in,out] left input: the starting point for hunt.
|
---|
| 48 | // output: the left index of hunted region.
|
---|
| 49 | // @param[out] right the right index of hunted region.
|
---|
| 50 | void hunt(T x, unsigned int &left, unsigned int &right);
|
---|
| 51 |
|
---|
[2730] | 52 | // Storage for previous result.
|
---|
[2727] | 53 | unsigned int prev_;
|
---|
| 54 | };
|
---|
| 55 |
|
---|
| 56 | }
|
---|
[2731] | 57 |
|
---|
| 58 | #include "HuntLocator.tcc"
|
---|
| 59 |
|
---|
[2727] | 60 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.