Resolve/C++ Catalog
CT/Bag/Put_To_1.h
Copyright © 2010, Reusable Software Research Group, The Ohio State University

//  /*--------------------------------------------------------------------*\
//  |   Concrete Template : Bag_Put_To_1
//  \*--------------------------------------------------------------------*/

#ifndef CT_BAG_PUT_TO_1
#define CT_BAG_PUT_TO_1 1

///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------

#include "AT/General/Put_To.h"
/*!
    #include "AT/Bag/Kernel.h"
!*/

///------------------------------------------------------------------------
/// Interface -------------------------------------------------------------
///------------------------------------------------------------------------

concrete_template <
	concrete_instance class Item,
	concrete_instance class Bag_Base
	/*!
	    implements
		abstract_instance Bag_Kernel <Item>
	!*/
    >
class Bag_Put_To_1 :
    extends
	concrete_instance Bag_Base,
    implements
	abstract_instance General_Put_To <Bag_Base>
{
public:
    
    procedure_body Put_To (
	    alters Character_OStream& outs
	)
    {
	object catalyst Bag_Put_To_1 temp;

	self &= temp;

	outs.Open_Scope ("{");
    
	// Display contents

	while (temp.Size () > 0)
	/*!
	    alters self, temp
	    maintains
		temp union self = #temp union #self  and
		temp intersection self = {}  and
		[items in self have been output already]
	    decreases
		|temp|
	!*/
	{
	    object catalyst Item x;
	    
	    temp.Remove_Any (x);
	    outs.New_Line ();
	    outs << x;

	    self.Add (x);
	}

	outs.Close_Scope ("}");

    }
};

//-------------------------------------------------------------------------

#endif // CT_BAG_PUT_TO_1

Last modified: Thu Jan 11 17:05:57 EST 2007