Changeset 12bbb367
- Timestamp:
- Mar 9, 2018, 10:56:32 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f86c8e5
- Parents:
- e59f0bf
- git-author:
- Aaron Moss <a3moss@…> (03/09/18 10:55:43)
- git-committer:
- Aaron Moss <a3moss@…> (03/09/18 10:56:32)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
re59f0bf r12bbb367 2904 2904 T value; 2905 2905 node * next; 2906 node( const T & v, node * n = nullptr ) : value( v ), next( n) {}2906 node( const T & v, node * n = nullptr ) : value( v ), next( n ) {} 2907 2907 }; 2908 2908 node * head; … … 2915 2915 head = nullptr; 2916 2916 } 2917 void copy( const stack<T> & o ) {2917 void copy( const stack<T> & o ) { 2918 2918 node ** crnt = &head; 2919 for ( node * next = o.head; ;next; next = next->next ) {2919 for ( node * next = o.head; next; next = next->next ) { 2920 2920 *crnt = new node{ next->value }; /***/ 2921 2921 crnt = &(*crnt)->next; … … 2924 2924 } 2925 2925 stack() : head( nullptr) {} 2926 stack( const stack<T> & o ) { copy( o); }2927 stack( stack<T> && o ) : head( o.head) { o.head = nullptr; }2926 stack( const stack<T> & o ) { copy( o ); } 2927 stack( stack<T> && o ) : head( o.head) { o.head = nullptr; } 2928 2928 ~stack() { clear(); } 2929 2929 stack & operator= ( const stack<T> & o) { 2930 2930 if ( this == &o ) return *this; 2931 2931 clear(); 2932 copy( o );2932 copy( o ); 2933 2933 return *this; 2934 2934 } 2935 stack & operator= ( stack<T> && o ) {2935 stack & operator= ( stack<T> && o ) { 2936 2936 if ( this == &o ) return *this; 2937 2937 head = o.head; … … 2940 2940 } 2941 2941 bool empty() const { return head == nullptr; } 2942 void push( const T & value ) { head = new node{ value, head }; /***/ }2942 void push( const T & value ) { head = new node{ value, head }; /***/ } 2943 2943 T pop() { 2944 2944 node * n = head; 2945 2945 head = n->next; 2946 T x = std::move( n->value );2946 T x = std::move( n->value ); 2947 2947 delete n; 2948 2948 return x;
Note: See TracChangeset
for help on using the changeset viewer.