// /*-------------------------------------------------------------------*\
// | Concrete Template : Binary_Tree_Put_To_2
// \*-------------------------------------------------------------------*/
#ifndef CT_BINARY_TREE_PUT_TO_2
#define CT_BINARY_TREE_PUT_TO_2 1
///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------
#include "AT/General/Put_To.h"
/*!
#include "AT/Binary_Tree/Kernel.h"
!*/
///------------------------------------------------------------------------
/// Interface -------------------------------------------------------------
///------------------------------------------------------------------------
concrete_template <
concrete_instance class Item,
/*!
implements
abstract_instance General_Put_To <Item>
!*/
concrete_instance class Binary_Tree_Base
/*!
implements
abstract_instance Binary_Tree_Kernel <
Item,
Binary_Tree_Base
>
!*/
>
class Binary_Tree_Put_To_2 :
extends
concrete_instance Binary_Tree_Base,
implements
abstract_instance General_Put_To <Binary_Tree_Base>
{
public:
/*!
math definition OUTPUT_REP (
x: binary tree of Item
): string of character is
[x displayed "on its side" in infix format and
appropriately indented]
!*/
procedure_body Put_To (
alters Character_OStream& outs
)
{
if (self.Size () == 0)
{
outs.New_Line ();
outs << "[empty_tree]";
}
else
{
object Integer tab_stops;
object catalyst Item root;
object catalyst Binary_Tree_Put_To_2 left, right;
self.Decompose (root, left, right);
// Remember tab stop setting and then make it 6; it needs to
// be pretty big for this to look decent!
tab_stops = outs.Get_Tab ();
outs.Set_Tab (6);
// Open scope to indent right subtree, then output it, and get
// back to original indent level
outs.Open_Scope ("");
outs << right;
outs.Close_Scope ("/");
// Output root
outs.New_Line ();
outs << root;
// Open scope to indent left subtree, then output it, and get
// back to original indent level
outs.Open_Scope ("\\"); // really just a single backslash!
outs << left;
outs.Close_Scope ("");
// Restore tab stop setting
outs.Set_Tab (tab_stops);
self.Compose (root, left, right);
}
}
};
//-------------------------------------------------------------------------
#endif // CT_BINARY_TREE_PUT_TO_2
Last modified: Thu Jan 11 17:05:57 EST 2007