21 #ifndef Rcpp__sugar__max_h
22 #define Rcpp__sugar__max_h
27 template <
int RTYPE,
bool NA,
typename T>
35 R_xlen_t n =
obj.size();
36 if (n == 0)
return(
static_cast<STORAGE>(R_NegInf));
40 if( Rcpp::traits::is_na<RTYPE>(
max ) )
return max ;
41 for( R_xlen_t i=1; i<n; i++){
43 if( Rcpp::traits::is_na<RTYPE>( current ) )
return current;
44 if( current >
max )
max = current ;
54 template <
int RTYPE,
typename T>
55 class Max<RTYPE,false,T> {
62 R_xlen_t n =
obj.size();
63 if (n == 0)
return(
static_cast<STORAGE>(R_NegInf));
67 for( R_xlen_t i=1; i<n; i++){
69 if( current >
max )
max = current ;
81 template <
int RTYPE,
bool NA,
typename T>
Rcpp::traits::storage_type< RTYPE >::type STORAGE
Rcpp::traits::storage_type< RTYPE >::type STORAGE
sugar::Max< RTYPE, NA, T > max(const VectorBase< RTYPE, NA, T > &x)