@@ -83,8 +83,8 @@ class Vector :
8383 Storage::set__ ( Rf_allocVector ( RTYPE, obj.get () ) ) ;
8484 }
8585
86- Vector ( const int & size, const stored_type& u ) {
87- RCPP_DEBUG_2 ( " Vector<%d>( const int & size = %d, const stored_type& u )" , RTYPE, size)
86+ Vector ( const R_xlen_t & size, const stored_type& u ) {
87+ RCPP_DEBUG_2 ( " Vector<%d>( const R_xlen_t & size = %d, const stored_type& u )" , RTYPE, size)
8888 Storage::set__ ( Rf_allocVector ( RTYPE, size) ) ;
8989 fill ( u ) ;
9090 }
@@ -107,10 +107,22 @@ class Vector :
107107 std::generate ( begin (), end (), gen );
108108 }
109109
110+ Vector ( const R_xlen_t& siz, stored_type (*gen)(void ) ) {
111+ RCPP_DEBUG_2 ( " Vector<%d>( const R_xlen_t& siz = %s, stored_type (*gen)(void) )" , RTYPE, siz )
112+ Storage::set__ ( Rf_allocVector ( RTYPE, siz) ) ;
113+ std::generate ( begin (), end (), gen );
114+ }
115+
116+ Vector ( const R_xlen_t& size ) {
117+ Storage::set__ ( Rf_allocVector ( RTYPE, size) ) ;
118+ init () ;
119+ }
120+
110121 Vector ( const int & size ) {
111122 Storage::set__ ( Rf_allocVector ( RTYPE, size) ) ;
112123 init () ;
113124 }
125+
114126 Vector ( const Dimension& dims) {
115127 Storage::set__ ( Rf_allocVector ( RTYPE, dims.prod () ) ) ;
116128 init () ;
@@ -145,8 +157,8 @@ class Vector :
145157 import_sugar_expression ( other, typename traits::same_type<Vector,VEC>::type () ) ;
146158 }
147159 template <typename U>
148- Vector ( const int & size, const U& u) {
149- RCPP_DEBUG_2 ( " Vector<%d>( const int & size, const U& u )" , RTYPE, size )
160+ Vector ( const R_xlen_t & size, const U& u) {
161+ RCPP_DEBUG_2 ( " Vector<%d>( const R_xlen_t & size, const U& u )" , RTYPE, size )
150162 Storage::set__ ( Rf_allocVector ( RTYPE, size) ) ;
151163 fill_or_generate ( u ) ;
152164 }
@@ -157,25 +169,25 @@ class Vector :
157169 }
158170
159171 template <typename U1>
160- Vector ( const int & siz, stored_type (*gen)(U1), const U1& u1) {
172+ Vector ( const R_xlen_t & siz, stored_type (*gen)(U1), const U1& u1) {
161173 Storage::set__ ( Rf_allocVector ( RTYPE, siz) ) ;
162- RCPP_DEBUG_2 ( " const int & siz, stored_type (*gen)(U1), const U1& u1 )" , RTYPE, siz )
174+ RCPP_DEBUG_2 ( " const R_xlen_t & siz, stored_type (*gen)(U1), const U1& u1 )" , RTYPE, siz )
163175 iterator first = begin (), last = end () ;
164176 while ( first != last ) *first++ = gen (u1) ;
165177 }
166178
167179 template <typename U1, typename U2>
168- Vector ( const int & siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2) {
180+ Vector ( const R_xlen_t & siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2) {
169181 Storage::set__ ( Rf_allocVector ( RTYPE, siz) ) ;
170- RCPP_DEBUG_2 ( " const int & siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2)" , RTYPE, siz )
182+ RCPP_DEBUG_2 ( " const R_xlen_t & siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2)" , RTYPE, siz )
171183 iterator first = begin (), last = end () ;
172184 while ( first != last ) *first++ = gen (u1,u2) ;
173185 }
174186
175187 template <typename U1, typename U2, typename U3>
176- Vector ( const int & siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3) {
188+ Vector ( const R_xlen_t & siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3) {
177189 Storage::set__ ( Rf_allocVector ( RTYPE, siz) ) ;
178- RCPP_DEBUG_2 ( " const int & siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3)" , RTYPE, siz )
190+ RCPP_DEBUG_2 ( " const R_xlen_t & siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3)" , RTYPE, siz )
179191 iterator first = begin (), last = end () ;
180192 while ( first != last ) *first++ = gen (u1,u2,u3) ;
181193 }
@@ -188,9 +200,9 @@ class Vector :
188200 }
189201
190202 template <typename InputIterator>
191- Vector ( InputIterator first, InputIterator last, int n) {
203+ Vector ( InputIterator first, InputIterator last, R_xlen_t n) {
192204 Storage::set__ (Rf_allocVector (RTYPE, n)) ;
193- RCPP_DEBUG_2 ( " Vector<%d>( InputIterator first, InputIterator last, int n = %d)" , RTYPE, n )
205+ RCPP_DEBUG_2 ( " Vector<%d>( InputIterator first, InputIterator last, R_xlen_t n = %d)" , RTYPE, n )
194206 std::copy ( first, last, begin () ) ;
195207 }
196208
@@ -202,9 +214,9 @@ class Vector :
202214 }
203215
204216 template <typename InputIterator, typename Func>
205- Vector ( InputIterator first, InputIterator last, Func func, int n){
217+ Vector ( InputIterator first, InputIterator last, Func func, R_xlen_t n){
206218 Storage::set__ ( Rf_allocVector ( RTYPE, n ) );
207- RCPP_DEBUG_2 ( " Vector<%d>( InputIterator, InputIterator, Func, int n = %d )" , RTYPE, n )
219+ RCPP_DEBUG_2 ( " Vector<%d>( InputIterator, InputIterator, Func, R_xlen_t n = %d )" , RTYPE, n )
208220 std::transform ( first, last, begin (), func) ;
209221 }
210222
@@ -450,31 +462,31 @@ class Vector :
450462 }
451463
452464 template <typename U>
453- static void replace_element ( iterator it, SEXP names, int index, const U& u){
465+ static void replace_element ( iterator it, SEXP names, R_xlen_t index, const U& u){
454466 replace_element__dispatch ( typename traits::is_named<U>::type (),
455467 it, names, index, u ) ;
456468 }
457469
458470 template <typename U>
459- static void replace_element__dispatch ( traits::false_type, iterator it, SEXP names, int index, const U& u){
471+ static void replace_element__dispatch ( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){
460472 *it = converter_type::get (u);
461473 }
462474
463475 template <typename U>
464- static void replace_element__dispatch ( traits::true_type, iterator it, SEXP names, int index, const U& u){
476+ static void replace_element__dispatch ( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){
465477 replace_element__dispatch__isArgument ( typename traits::same_type<U,Argument>(), it, names, index, u ) ;
466478 }
467479
468480 template <typename U>
469- static void replace_element__dispatch__isArgument ( traits::false_type, iterator it, SEXP names, int index, const U& u){
481+ static void replace_element__dispatch__isArgument ( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){
470482 RCPP_DEBUG_2 ( " Vector::replace_element__dispatch<%s>(true, index= %d) " , DEMANGLE (U), index ) ;
471483
472484 *it = converter_type::get (u.object ) ;
473485 SET_STRING_ELT ( names, index, ::Rf_mkChar ( u.name .c_str () ) ) ;
474486 }
475487
476488 template <typename U>
477- static void replace_element__dispatch__isArgument ( traits::true_type, iterator it, SEXP names, int index, const U& u){
489+ static void replace_element__dispatch__isArgument ( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){
478490 RCPP_DEBUG_2 ( " Vector::replace_element__dispatch<%s>(true, index= %d) " , DEMANGLE (U), index ) ;
479491
480492 *it = R_MissingArg ;
@@ -525,8 +537,8 @@ class Vector :
525537 bool containsElementNamed ( const char * target ) const {
526538 SEXP names = RCPP_GET_NAMES (Storage::get__ ()) ;
527539 if ( Rf_isNull (names) ) return false ;
528- int n = Rf_length (names) ;
529- for ( int i=0 ; i<n; i++){
540+ R_xlen_t n = Rf_length (names) ;
541+ for ( R_xlen_t i=0 ; i<n; i++){
530542 if ( !strcmp ( target, CHAR (STRING_ELT (names, i)) ) )
531543 return true ;
532544 }
@@ -536,8 +548,8 @@ class Vector :
536548 int findName (const std::string& name) const {
537549 SEXP names = RCPP_GET_NAMES (Storage::get__ ());
538550 if (Rf_isNull (names)) stop (" 'names' attribute is null" );
539- int n = Rf_length (names);
540- for (int i=0 ; i < n; ++i) {
551+ R_xlen_t n = Rf_length (names);
552+ for (R_xlen_t i=0 ; i < n; ++i) {
541553 if (strcmp (name.c_str (), CHAR (STRING_ELT (names, i))) == 0 ) {
542554 return i;
543555 }
0 commit comments