Rcpp Version 1.0.9
StretchyList.h
Go to the documentation of this file.
1 // Copyright (C) 2013 Romain Francois
2 //
3 // This file is part of Rcpp.
4 //
5 // Rcpp is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // Rcpp is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef Rcpp_api_meat_StretchyList_h
19 #define Rcpp_api_meat_StretchyList_h
20 
21 namespace Rcpp{
22 
23  template< template <class> class StoragePolicy>
24  template< typename T>
25  StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back__impl( const T& obj, traits::false_type ){
26  Shield<SEXP> s( wrap(obj) ) ;
27  SEXP tmp = Rf_cons( s, R_NilValue );
28  SEXP self = Storage::get__() ;
29  SETCDR( CAR(self), tmp) ;
30  SETCAR( self, tmp ) ;
31  return *this ;
32  }
33 
34  template< template <class> class StoragePolicy>
35  template< typename T>
36  StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back__impl( const T& obj, traits::true_type ){
37  Shield<SEXP> s( wrap(obj.object) ) ;
38  SEXP tmp = Rf_cons( s, R_NilValue );
39  Symbol tag = obj.name ;
40  SET_TAG(tmp, tag) ;
41  SEXP self = Storage::get__() ;
42  SETCDR( CAR(self), tmp) ;
43  SETCAR( self, tmp ) ;
44  return *this ;
45  }
46 
47  template< template <class> class StoragePolicy>
48  template< typename T>
49  StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front__impl( const T& obj, traits::false_type){
50  SEXP tmp ;
51  SEXP self = Storage::get__() ;
52  Shield<SEXP> s( wrap(obj) ) ;
53  tmp = Rf_cons(s, CDR(self) ) ;
54  SETCDR(self, tmp) ;
55  return *this ;
56  }
57 
58  template< template <class> class StoragePolicy>
59  template< typename T>
60  StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front__impl( const T& obj, traits::true_type){
61  SEXP tmp ;
62  SEXP self = Storage::get__() ;
63  Shield<SEXP> s( wrap(obj.object) ) ;
64  Symbol tag = obj.name ;
65  tmp = Rf_cons(s, CDR(self) ) ;
66  SET_TAG(tmp, tag );
67  SETCDR(self, tmp) ;
68  return *this ;
69  }
70 
71 
72 }
73 
74 #endif
integral_constant< bool, true > true_type
integral_constant< bool, false > false_type
Rcpp API.
Definition: algo.h:28
StretchyList_Impl & push_front__impl(const T &obj, traits::false_type)
StretchyList_Impl & push_back__impl(const T &obj, traits::false_type)
Symbol_Impl< NoProtectStorage > Symbol
Definition: Symbol.h:82
SEXP wrap(const Date &date)
Definition: Date.h:38