Skip to content

Commit 3348462

Browse files
authored
Merge pull request #568 from thirdwing/iss391_patch3
Range sugar uses R_xlen_t as start/end type
2 parents adae3fe + 6f33d4c commit 3348462

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

ChangeLog

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2016-10-24 Qiang Kou <[email protected]>
2+
3+
* inst/include/Rcpp/sugar/Range.h: Range sugar uses R_xlen_t as start/end type
4+
15
2016-10-23 Nathan Russell <[email protected]>
26

37
* inst/include/Rcpp/sugar/matrix/eye.h: New functions
@@ -7,12 +11,12 @@
711
* inst/unitTests/runit.sugar.R: Idem
812
* inst/unitTests/runit.dispatch.R (test.ExpressionVector): Use
913
expression rather than parse, correct typo
14+
1015
2016-10-22 Qiang Kou <[email protected]>
1116

1217
* inst/include/Rcpp/hash/IndexHash.h: change hashing function to return unsigned int
1318
* inst/include/Rcpp/hash/SelfHash.h: Ditto
1419

15-
1620
2016-10-21 Qiang Kou <[email protected]>
1721

1822
* inst/include/Rcpp/barrier.h: Change string_elt/vector_elt to accept R_xlen_t

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
fixing \ghit{549})
1919
\item Added new (matrix) Sugar functions \code{eye()},
2020
\code{ones()}, \code{zeros()} (PR \ghpr{566} by Nathan Russell)
21+
\item \code{Range} Sugar now used \code{R_xlen_t} type for start/end
22+
(PR \ghpr{568} by Qiang Kou)
2123
}
2224
\item Changes in Rcpp unit tests
2325
\itemize{

inst/include/Rcpp/sugar/Range.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ namespace Rcpp{
2626

2727
class Range : public VectorBase<INTSXP,false, Range >{
2828
public:
29-
Range( int start_, int end__ ) : start(start_), end_(end__){
29+
Range( R_xlen_t start_, R_xlen_t end__ ) : start(start_), end_(end__){
3030
if( start_ > end__ ){
3131
throw std::range_error( "upper value must be greater than lower value" ) ;
3232
}
3333
}
3434

35-
inline int size() const{
35+
inline R_xlen_t size() const{
3636
return end_ - start + 1;
3737
}
3838

39-
inline int operator[]( int i) const {
39+
inline R_xlen_t operator[]( R_xlen_t i) const {
4040
return start + i ;
4141
}
4242

@@ -60,29 +60,31 @@ namespace Rcpp{
6060
return orig ;
6161
}
6262

63-
Range& operator+=(int n) {
63+
Range& operator+=(R_xlen_t n) {
6464
start += n ; end_ += n ;
6565
return *this ;
6666
}
6767

68-
Range& operator-=(int n) {
68+
Range& operator-=(R_xlen_t n) {
6969
start -= n ; end_ -= n ;
7070
return *this ;
7171
}
7272

73-
Range operator+( int n ){
73+
Range operator+( R_xlen_t n ){
7474
return Range( start + n, end_ + n ) ;
7575
}
76-
Range operator-( int n ){
76+
77+
Range operator-( R_xlen_t n ){
7778
return Range( start - n, end_ - n ) ;
7879
}
7980

80-
inline int get_start() const { return start ; }
81-
inline int get_end() const { return end_ ; }
81+
inline R_xlen_t get_start() const { return start ; }
82+
83+
inline R_xlen_t get_end() const { return end_ ; }
8284

8385
private:
84-
int start ;
85-
int end_ ;
86+
R_xlen_t start ;
87+
R_xlen_t end_ ;
8688
} ;
8789

8890
}

0 commit comments

Comments
 (0)