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

Class Range

inst/include/Rcpp/sugar/functions/range.h:29–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

seqFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected