-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrev.h
More file actions
35 lines (26 loc) · 774 Bytes
/
rev.h
File metadata and controls
35 lines (26 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef Rcpp__sugar__rev_h
#define Rcpp__sugar__rev_h
namespace Rcpp{
namespace sugar{
template <int RTYPE, bool NA, typename T>
class Rev : public Rcpp::VectorBase< RTYPE ,NA, Rev<RTYPE,NA,T> > {
public:
typedef typename Rcpp::VectorBase<RTYPE,NA,T> VEC_TYPE ;
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
Rev( const VEC_TYPE& object_ ) :
object(object_), n(object_.size() - 1) {}
inline STORAGE operator[]( int i ) const {
return object[n - i] ;
}
inline int size() const { return n + 1; }
private:
const VEC_TYPE& object ;
int n ;
} ;
} // sugar
template <int RTYPE,bool NA, typename T>
inline sugar::Rev<RTYPE,NA,T> rev( const VectorBase<RTYPE,NA,T>& t){
return sugar::Rev<RTYPE,NA,T>( t ) ;
}
} // Rcpp
#endif