| 52 | |
| 53 | template <typename KeyT, typename ValT> |
| 54 | inline ValT Interp(const KeyT& k, const InterpData<KeyT, ValT>* array, const int n) { |
| 55 | if (n < 1) { |
| 56 | return ValT(0); |
| 57 | } |
| 58 | |
| 59 | int low_idx = -1; |
| 60 | int high_idx = -1; |
| 61 | |
| 62 | SelectInterpPoints<KeyT, ValT>(k, array, n, &low_idx, &high_idx); |
| 63 | |
| 64 | if (low_idx == high_idx) { |
| 65 | return array[low_idx].val; |
| 66 | } |
| 67 | |
| 68 | const InterpData<KeyT, ValT>* curr = &array[low_idx]; |
| 69 | const InterpData<KeyT, ValT>* next = &array[high_idx]; |
| 70 | // map(...) only works on integers. MapT<> is the same thing but it works on |
| 71 | // all datatypes. |
| 72 | return MapT<KeyT, ValT>(k, curr->key, next->key, curr->val, next->val); |
| 73 | } |
| 74 | |
| 75 | #endif // APPROXIMATING_FUNCTION_H_ |
no outgoing calls
no test coverage detected