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

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

#ifndef CT_SET_PUT_TO_1
#define CT_SET_PUT_TO_1 1

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

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

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

concrete_template <
	concrete_instance class Item,
	/*!
	    implements
		abstract_instance General_Put_To <Item>
	!*/
	concrete_instance class Set_Base
	/*!
	    implements
		abstract_instance Set_Kernel <Item>
	!*/
    >
class Set_Put_To_1 :
    extends
	concrete_instance Set_Base,
    implements
	abstract_instance General_Put_To <Set_Base>
{
public:
    
    procedure_body Put_To (
	    alters Character_OStream& outs
	)
    {
	object catalyst Set_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;
	    if (temp.Size () > 0)
	    {
		outs << ',';
	    }

	    self.Add (x);
	}

	outs.Close_Scope ("}");
    }

};

#endif // CT_SET_PUT_TO_1

Last modified: Mon Apr 09 15:34:36 EDT 2007