Skip to content

Commit 9b8c681

Browse files
author
thirdwing
committed
sugar operators
1 parent ac8c131 commit 9b8c681

File tree

9 files changed

+144
-144
lines changed

9 files changed

+144
-144
lines changed

inst/include/Rcpp/sugar/operators/Comparator.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class Comparator :
3737
Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
3838
lhs(lhs_), rhs(rhs_), op() {}
3939

40-
inline int operator[]( int i ) const {
40+
inline int operator[]( R_xlen_t i ) const {
4141
STORAGE x = lhs[i] ;
4242
if( Rcpp::traits::is_na<RTYPE>( x ) ) return NA_LOGICAL ;
4343
STORAGE y = rhs[i] ;
4444
if( Rcpp::traits::is_na<RTYPE>( y ) ) return NA_LOGICAL ;
4545
return op( x, y ) ;
4646
}
4747

48-
inline int size() const { return lhs.size() ; }
48+
inline R_xlen_t size() const { return lhs.size() ; }
4949

5050
private:
5151
const LHS_TYPE& lhs ;
@@ -68,13 +68,13 @@ class Comparator<RTYPE,Operator,false,LHS_T,RHS_NA,RHS_T> :
6868
Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
6969
lhs(lhs_), rhs(rhs_), op() {}
7070

71-
inline int operator[]( int i ) const {
71+
inline int operator[]( R_xlen_t i ) const {
7272
STORAGE y = rhs[i] ;
7373
if( Rcpp::traits::is_na<RTYPE>( y ) ) return NA_LOGICAL ;
7474
return op( lhs[i], y ) ;
7575
}
7676

77-
inline int size() const { return lhs.size() ; }
77+
inline R_xlen_t size() const { return lhs.size() ; }
7878

7979
private:
8080
const LHS_TYPE& lhs ;
@@ -96,11 +96,11 @@ class Comparator<RTYPE,Operator,false,LHS_T,false,RHS_T> :
9696
Comparator( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_) :
9797
lhs(lhs_), rhs(rhs_), op() {}
9898

99-
inline int operator[]( int i ) const {
99+
inline int operator[]( R_xlen_t i ) const {
100100
return op( lhs[i], rhs[i] ) ;
101101
}
102102

103-
inline int size() const { return lhs.size() ; }
103+
inline R_xlen_t size() const { return lhs.size() ; }
104104

105105
private:
106106
const LHS_TYPE& lhs ;

inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class Comparator_With_One_Value : public ::Rcpp::VectorBase< LGLSXP, true, Compa
4141

4242
}
4343

44-
inline int operator[]( int i ) const {
44+
inline int operator[]( R_xlen_t i ) const {
4545
return (this->*m)(i) ;
4646
}
4747

48-
inline int size() const { return lhs.size() ; }
48+
inline R_xlen_t size() const { return lhs.size() ; }
4949

5050
private:
5151
const VEC_TYPE& lhs ;
@@ -54,7 +54,7 @@ class Comparator_With_One_Value : public ::Rcpp::VectorBase< LGLSXP, true, Compa
5454
Operator op ;
5555

5656
inline int rhs_is_na(int i) const { return rhs ; }
57-
inline int rhs_is_not_na(int i) const {
57+
inline int rhs_is_not_na(R_xlen_t i) const {
5858
STORAGE x = lhs[i] ;
5959
return Rcpp::traits::is_na<RTYPE>(x) ? x : op( x, rhs ) ;
6060
}
@@ -80,11 +80,11 @@ class Comparator_With_One_Value<RTYPE,Operator,false,T> :
8080

8181
}
8282

83-
inline int operator[]( int i ) const {
83+
inline int operator[]( R_xlen_t i ) const {
8484
return (this->*m)(i) ;
8585
}
8686

87-
inline int size() const { return lhs.size() ; }
87+
inline R_xlen_t size() const { return lhs.size() ; }
8888

8989
private:
9090
const VEC_TYPE& lhs ;

inst/include/Rcpp/sugar/operators/divides.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ namespace sugar{
3737
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
3838
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
3939

40-
inline STORAGE operator[]( int i ) const {
40+
inline STORAGE operator[]( R_xlen_t i ) const {
4141
STORAGE x = lhs[i] ;
4242
if( Rcpp::traits::is_na<RTYPE>( x ) ) return x ;
4343
STORAGE y = rhs[i] ;
4444
return Rcpp::traits::is_na<RTYPE>( y ) ? y : ( x / y ) ;
4545
}
4646

47-
inline int size() const { return lhs.size() ; }
47+
inline R_xlen_t size() const { return lhs.size() ; }
4848

4949
private:
5050
const LHS_EXT& lhs ;
@@ -63,11 +63,11 @@ namespace sugar{
6363
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
6464
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
6565

66-
inline double operator[]( int i ) const {
66+
inline double operator[]( R_xlen_t i ) const {
6767
return lhs[i] / rhs[i] ;
6868
}
6969

70-
inline int size() const { return lhs.size() ; }
70+
inline R_xlen_t size() const { return lhs.size() ; }
7171

7272
private:
7373
const LHS_EXT& lhs ;
@@ -87,13 +87,13 @@ namespace sugar{
8787
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
8888
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
8989

90-
inline STORAGE operator[]( int i ) const {
90+
inline STORAGE operator[]( R_xlen_t i ) const {
9191
STORAGE y = rhs[i] ;
9292
if( Rcpp::traits::is_na<RTYPE>( y ) ) return y ;
9393
return lhs[i] / y ;
9494
}
9595

96-
inline int size() const { return lhs.size() ; }
96+
inline R_xlen_t size() const { return lhs.size() ; }
9797

9898
private:
9999
const LHS_EXT& lhs ;
@@ -112,11 +112,11 @@ namespace sugar{
112112
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
113113
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
114114

115-
inline double operator[]( int i ) const {
115+
inline double operator[]( R_xlen_t i ) const {
116116
return lhs[i] / rhs[i] ;
117117
}
118118

119-
inline int size() const { return lhs.size() ; }
119+
inline R_xlen_t size() const { return lhs.size() ; }
120120

121121
private:
122122
const LHS_EXT& lhs ;
@@ -137,12 +137,12 @@ namespace sugar{
137137
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
138138
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
139139

140-
inline STORAGE operator[]( int i ) const {
140+
inline STORAGE operator[]( R_xlen_t i ) const {
141141
STORAGE x = lhs[i] ;
142142
if( Rcpp::traits::is_na<RTYPE>( x ) ) return x ;
143143
return x / rhs[i] ;
144144
}
145-
inline int size() const { return lhs.size() ; }
145+
inline R_xlen_t size() const { return lhs.size() ; }
146146

147147
private:
148148
const LHS_EXT& lhs ;
@@ -161,10 +161,10 @@ namespace sugar{
161161
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
162162
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
163163

164-
inline double operator[]( int i ) const {
164+
inline double operator[]( R_xlen_t i ) const {
165165
return lhs[i] / rhs[i] ;
166166
}
167-
inline int size() const { return lhs.size() ; }
167+
inline R_xlen_t size() const { return lhs.size() ; }
168168

169169
private:
170170
const LHS_EXT& lhs ;
@@ -185,11 +185,11 @@ namespace sugar{
185185
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
186186
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
187187

188-
inline STORAGE operator[]( int i ) const {
188+
inline STORAGE operator[]( R_xlen_t i ) const {
189189
return lhs[i] / rhs[i] ;
190190
}
191191

192-
inline int size() const { return lhs.size() ; }
192+
inline R_xlen_t size() const { return lhs.size() ; }
193193

194194
private:
195195
const LHS_EXT& lhs ;
@@ -208,11 +208,11 @@ namespace sugar{
208208
Divides_Vector_Vector( const LHS_TYPE& lhs_, const RHS_TYPE& rhs_ ) :
209209
lhs(lhs_.get_ref()), rhs(rhs_.get_ref()) {}
210210

211-
inline double operator[]( int i ) const {
211+
inline double operator[]( R_xlen_t i ) const {
212212
return lhs[i] / rhs[i] ;
213213
}
214214

215-
inline int size() const { return lhs.size() ; }
215+
inline R_xlen_t size() const { return lhs.size() ; }
216216

217217
private:
218218
const LHS_EXT& lhs ;
@@ -234,13 +234,13 @@ namespace sugar{
234234
lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {
235235
}
236236

237-
inline STORAGE operator[]( int i ) const {
237+
inline STORAGE operator[]( R_xlen_t i ) const {
238238
if(rhs_na) return rhs ;
239239
STORAGE x = lhs[i] ;
240240
return Rcpp::traits::is_na<RTYPE>(x) ? x : (x / rhs) ;
241241
}
242242

243-
inline int size() const { return lhs.size() ; }
243+
inline R_xlen_t size() const { return lhs.size() ; }
244244

245245
private:
246246
const VEC_EXT& lhs ;
@@ -259,11 +259,11 @@ namespace sugar{
259259
lhs(lhs_.get_ref()), rhs(rhs_) {
260260
}
261261

262-
inline double operator[]( int i ) const {
262+
inline double operator[]( R_xlen_t i ) const {
263263
return lhs[i] / rhs ;
264264
}
265265

266-
inline int size() const { return lhs.size() ; }
266+
inline R_xlen_t size() const { return lhs.size() ; }
267267

268268
private:
269269
const VEC_EXT& lhs ;
@@ -283,12 +283,12 @@ namespace sugar{
283283
Divides_Vector_Primitive( const VEC_TYPE& lhs_, STORAGE rhs_ ) :
284284
lhs(lhs_.get_ref()), rhs(rhs_), rhs_na( Rcpp::traits::is_na<RTYPE>(rhs_) ) {}
285285

286-
inline STORAGE operator[]( int i ) const {
286+
inline STORAGE operator[]( R_xlen_t i ) const {
287287
if( rhs_na ) return rhs ;
288288
STORAGE x = lhs[i] ;
289289
return Rcpp::traits::is_na<RTYPE>(x) ? x : (x / rhs) ;
290290
}
291-
inline int size() const { return lhs.size() ; }
291+
inline R_xlen_t size() const { return lhs.size() ; }
292292

293293
private:
294294
const VEC_EXT& lhs ;
@@ -306,10 +306,10 @@ namespace sugar{
306306
Divides_Vector_Primitive( const VEC_TYPE& lhs_, double rhs_ ) :
307307
lhs(lhs_), rhs(rhs_){}
308308

309-
inline double operator[]( int i ) const {
309+
inline double operator[]( R_xlen_t i ) const {
310310
return lhs[i] / rhs ;
311311
}
312-
inline int size() const { return lhs.size() ; }
312+
inline R_xlen_t size() const { return lhs.size() ; }
313313

314314
private:
315315
const VEC_EXT& lhs ;
@@ -329,12 +329,12 @@ namespace sugar{
329329
Divides_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
330330
lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
331331

332-
inline STORAGE operator[]( int i ) const {
332+
inline STORAGE operator[]( R_xlen_t i ) const {
333333
if( lhs_na ) return lhs ;
334334
STORAGE x = rhs[i] ;
335335
return Rcpp::traits::is_na<RTYPE>(x) ? x : (lhs / x) ;
336336
}
337-
inline int size() const { return rhs.size() ; }
337+
inline R_xlen_t size() const { return rhs.size() ; }
338338
private:
339339
STORAGE lhs ;
340340
const VEC_EXT& rhs ;
@@ -351,10 +351,10 @@ namespace sugar{
351351
Divides_Primitive_Vector( double lhs_, const VEC_TYPE& rhs_ ) :
352352
lhs(lhs_), rhs(rhs_.get_ref()) {}
353353

354-
inline double operator[]( int i ) const {
354+
inline double operator[]( R_xlen_t i ) const {
355355
return lhs / rhs[i] ;
356356
}
357-
inline int size() const { return rhs.size() ; }
357+
inline R_xlen_t size() const { return rhs.size() ; }
358358
private:
359359
double lhs ;
360360
const VEC_EXT& rhs ;
@@ -373,11 +373,11 @@ namespace sugar{
373373
Divides_Primitive_Vector( STORAGE lhs_, const VEC_TYPE& rhs_ ) :
374374
lhs(lhs_), rhs(rhs_.get_ref()), lhs_na( Rcpp::traits::is_na<RTYPE>(lhs_) ) {}
375375

376-
inline STORAGE operator[]( int i ) const {
376+
inline STORAGE operator[]( R_xlen_t i ) const {
377377
if( lhs_na ) return lhs ;
378378
return lhs / rhs[i] ;
379379
}
380-
inline int size() const { return rhs.size() ; }
380+
inline R_xlen_t size() const { return rhs.size() ; }
381381

382382
private:
383383
STORAGE lhs ;
@@ -395,10 +395,10 @@ namespace sugar{
395395
Divides_Primitive_Vector( double lhs_, const VEC_TYPE& rhs_ ) :
396396
lhs(lhs_), rhs(rhs_.get_ref()) {}
397397

398-
inline double operator[]( int i ) const {
398+
inline double operator[]( R_xlen_t i ) const {
399399
return lhs / rhs[i] ;
400400
}
401-
inline int size() const { return rhs.size() ; }
401+
inline R_xlen_t size() const { return rhs.size() ; }
402402

403403
private:
404404
double lhs ;

0 commit comments

Comments
 (0)