@@ -88,7 +88,7 @@ class Median {
88
88
public:
89
89
typedef typename median_detail::result<RTYPE>::type result_type;
90
90
typedef typename Rcpp::traits::storage_type<RTYPE>::type stored_type;
91
- enum { RTYPE2 = median_detail::result<RTYPE>::rtype };
91
+ enum { RESULT_RTYPE = median_detail::result<RTYPE>::rtype };
92
92
typedef T VECTOR;
93
93
94
94
private:
@@ -100,11 +100,11 @@ class Median {
100
100
101
101
operator result_type () {
102
102
if (x.size () < 1 ) {
103
- return Rcpp::traits::get_na<RTYPE2 >();
103
+ return Rcpp::traits::get_na<RESULT_RTYPE >();
104
104
}
105
105
106
106
if (Rcpp::any (Rcpp::is_na (x))) {
107
- return Rcpp::traits::get_na<RTYPE2 >();
107
+ return Rcpp::traits::get_na<RESULT_RTYPE >();
108
108
}
109
109
110
110
R_xlen_t n = x.size () / 2 ;
@@ -126,7 +126,7 @@ class Median<RTYPE, NA, T, true> {
126
126
public:
127
127
typedef typename median_detail::result<RTYPE>::type result_type;
128
128
typedef typename Rcpp::traits::storage_type<RTYPE>::type stored_type;
129
- enum { RTYPE2 = median_detail::result<RTYPE>::rtype };
129
+ enum { RESULT_RTYPE = median_detail::result<RTYPE>::rtype };
130
130
typedef T VECTOR;
131
131
132
132
private:
@@ -138,7 +138,7 @@ class Median<RTYPE, NA, T, true> {
138
138
139
139
operator result_type () {
140
140
if (!x.size ()) {
141
- return Rcpp::traits::get_na<RTYPE2 >();
141
+ return Rcpp::traits::get_na<RESULT_RTYPE >();
142
142
}
143
143
144
144
R_xlen_t n = x.size () / 2 ;
@@ -160,7 +160,7 @@ class Median<RTYPE, false, T, NA_RM> {
160
160
public:
161
161
typedef typename median_detail::result<RTYPE>::type result_type;
162
162
typedef typename Rcpp::traits::storage_type<RTYPE>::type stored_type;
163
- enum { RTYPE2 = median_detail::result<RTYPE>::rtype };
163
+ enum { RESULT_RTYPE = median_detail::result<RTYPE>::rtype };
164
164
typedef T VECTOR;
165
165
166
166
private:
@@ -172,7 +172,7 @@ class Median<RTYPE, false, T, NA_RM> {
172
172
173
173
operator result_type () {
174
174
if (x.size () < 1 ) {
175
- return Rcpp::traits::get_na<RTYPE2 >();
175
+ return Rcpp::traits::get_na<RESULT_RTYPE >();
176
176
}
177
177
178
178
R_xlen_t n = x.size () / 2 ;
@@ -281,14 +281,8 @@ class Median<STRSXP, false, T, true> {
281
281
template <int RTYPE, bool NA, typename T>
282
282
inline typename sugar::median_detail::result<RTYPE>::type
283
283
median (const Rcpp::VectorBase<RTYPE, NA, T>& x, bool na_rm = false ) {
284
- switch (static_cast <int >(na_rm)) {
285
- case 0 :
286
- return sugar::Median<RTYPE, NA, T, false >(x);
287
- case 1 :
288
- return sugar::Median<RTYPE, NA, T, true >(x);
289
- default :
290
- return Rcpp::traits::get_na<RTYPE>();
291
- }
284
+ if (!na_rm) return sugar::Median<RTYPE, NA, T, false >(x);
285
+ return sugar::Median<RTYPE, NA, T, true >(x);
292
286
}
293
287
294
288
} // Rcpp
0 commit comments