// /*-------------------------------------------------------------------*\ // | Concrete Template : Stack_Put_To_1 // \*-------------------------------------------------------------------*/ #ifndef CT_STACK_PUT_TO_1 #define CT_STACK_PUT_TO_1 1 ///------------------------------------------------------------------------ /// Global Context -------------------------------------------------------- ///------------------------------------------------------------------------ #include "AT/General/Put_To.h" /*! #include "AT/Stack/Kernel.h" !*/ ///------------------------------------------------------------------------ /// Interface ------------------------------------------------------------- ///------------------------------------------------------------------------ concrete_template < concrete_instance class Item, /*! implements abstract_instance General_Put_To !*/ concrete_instance class Stack_Base /*! implements abstract_instance Stack_Kernel !*/ > class Stack_Put_To_1 : extends concrete_instance Stack_Base, implements abstract_instance General_Put_To { public: procedure_body Put_To ( alters Character_OStream& outs ) { object catalyst Stack_Put_To_1 temp; // Open scope of string outs.Open_Scope ("<"); // Put contents of self while (self.Length () > 0) /*! alters self, temp maintains reverse (temp) * self = reverse (#temp) * #self and [items in temp have been output already]) decreases |self| !*/ { object catalyst Item x; self.Pop (x); outs.New_Line (); outs << x; temp.Push (x); } // Close scope of string outs.Close_Scope (">"); // Restore self while (temp.Length () > 0) /*! alters self, temp maintains reverse (temp) * self = reverse (#temp) * #self decreases |temp| !*/ { object catalyst Item x; temp.Pop (x); self.Push (x); } } }; #endif // CT_STACK_PUT_TO_1