| 33 | WhichMin(const VEC_TYPE& obj_ ) : obj(obj_){} |
| 34 | |
| 35 | R_xlen_t get() const { |
| 36 | STORAGE current = obj[0] ; |
| 37 | STORAGE min = current ; |
| 38 | R_xlen_t index = 0 ; |
| 39 | if( Rcpp::traits::is_na<RTYPE>(current) ) return NA_INTEGER ; |
| 40 | R_xlen_t n = obj.size() ; |
| 41 | for( R_xlen_t i=1; i<n; i++){ |
| 42 | current = obj[i] ; |
| 43 | if( Rcpp::traits::is_na<RTYPE>(current) ) return NA_INTEGER ; |
| 44 | if( current < min ){ |
| 45 | min = current ; |
| 46 | index = i ; |
| 47 | } |
| 48 | } |
| 49 | return index ; |
| 50 | } |
| 51 | |
| 52 | private: |
| 53 | const VEC_TYPE& obj ; |