MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / Max

Class Max

inst/include/Rcpp/sugar/functions/max.h:28–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27 template <int RTYPE, bool NA, typename T>
28 class Max {
29 public:
30 typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
31
32 Max( const T& obj_) : obj(obj_) {}
33
34 operator STORAGE() const {
35 R_xlen_t n = obj.size();
36 if (n == 0) return(static_cast<STORAGE>(R_NegInf));
37
38 STORAGE max, current ;
39 max = obj[0] ;
40 if( Rcpp::traits::is_na<RTYPE>( max ) ) return max ;
41 for( R_xlen_t i=1; i<n; i++){
42 current = obj[i] ;
43 if( Rcpp::traits::is_na<RTYPE>( current ) ) return current;
44 if( current > max ) max = current ;
45 }
46 return max ;
47 }
48
49 private:
50 const T& obj ;
51 } ;
52
53 // version for NA = false
54 template <int RTYPE, typename T>

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected