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

Class Range

inst/include/Rcpp/sugar/Range.h:27–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace Rcpp{
26
27 class Range : public VectorBase<INTSXP,false, Range >{
28 public:
29 Range( R_xlen_t start_, R_xlen_t end__ ) : start(start_), end_(end__){
30 if( start_ > end__ ){
31 throw std::range_error( "upper value must be greater than lower value" ) ;
32 }
33 }
34
35 inline R_xlen_t size() const{
36 return end_ - start + 1;
37 }
38
39 inline R_xlen_t operator[]( R_xlen_t i) const {
40 return start + i ;
41 }
42
43 Range& operator++() {
44 start++ ; end_++ ;
45 return *this ;
46 }
47 Range operator++(int) {
48 Range orig(*this) ;
49 ++(*this);
50 return orig ;
51 }
52
53 Range& operator--() {
54 start-- ; end_-- ;
55 return *this ;
56 }
57 Range operator--(int) {
58 Range orig(*this) ;
59 --(*this);
60 return orig ;
61 }
62
63 Range& operator+=( int n ) {
64 start += n ; end_ += n ;
65 return *this ;
66 }
67
68 Range& operator-=( int n ) {
69 start -= n ; end_ -= n ;
70 return *this ;
71 }
72
73 Range operator+( int n ){
74 return Range( start + n, end_ + n ) ;
75 }
76
77 Range operator-( int n ){
78 return Range( start - n, end_ - n ) ;
79 }
80
81 inline R_xlen_t get_start() const { return start ; }
82
83 inline R_xlen_t get_end() const { return end_ ; }
84

Callers 7

operator+Method · 0.70
operator-Method · 0.70
runit_SubMatrixFunction · 0.50
runit_RangeFunction · 0.50
runit_range_plusFunction · 0.50
runit_range_minusFunction · 0.50
operator()Method · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected