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

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

#ifndef CT_LIST_RETREAT_2
#define CT_LIST_RETREAT_2 1
 
///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------

#include "AT/List/Retreat.h"

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

concrete_template <
	concrete_instance class Item,
	concrete_instance class Node,
	/*!
	    implements
		abstract_instance Record <
			Item,
			Pointer_C <Node>,
			Pointer_C <Node>
		    >
	!*/
	concrete_instance class Rep =
            Representation <
		    Pointer_C <Node>,
		    Pointer_C <Node>,
		    Pointer_C <Node>,
		    Integer,
		    Integer
		>    
    >
class List_Retreat_2 :
    implements
	abstract_instance List_Retreat <Item>,
    encapsulates
	concrete_instance Rep
{
private:

    rep_field_name (Rep, 0, Pointer_C <Node>, pre_start);
    rep_field_name (Rep, 1, Pointer_C <Node>, last_left);
    rep_field_name (Rep, 2, Pointer_C <Node>, post_finish);
    rep_field_name (Rep, 3, Integer, left_length);
    rep_field_name (Rep, 4, Integer, right_length);

    field_name (Node, 0, Item, data);
    field_name (Node, 1, Pointer_C <Node>, next);
    field_name (Node, 2, Pointer_C <Node>, previous);

    /*!
	convention
	    self.pre_start /= NULL  and
	    self.last_left /= NULL  and
	    self.post_finish /= NULL  and
	    self.left_length >= 0  and
	    self.right_length >= 0  and
	    [self.pre_start points to the first node of a doubly-
	     linked list containing (self.left_length +
	     self.right_length + 2) Node nodes]  and 
	    [self.last_left points to the (self.left_length + 1)-th
	     node in the doubly-linked list of nodes]  and
	    [self.post_finish points to the last node in the
	     doubly-linked list of nodes]  and
	    [for every node n in the doubly-linked list of nodes,
	     except the one pointed to by self.pre_start,
	     n.previous.next = n]  and
	    [for every node n in the doubly-linked list of nodes,
	     except the one pointed to by self.post_finish,
	     n.next.previous = n]
	     
	correspondence
	    (if self.left_length = 0
		 then self.left = empty_string
	     else if self.left_length = 1
		 then self.left = <self.last_left.data>
	     else if self.left_length = 2
		 then self.left =
		     <self.pre_start.next.data> *
		     <self.last_left.data>
	     else [self.left = 
		 <self.pre_start.next.data> *
		 <self.pre_start.next.next.data> *
		 ... *
		 <self.last_left.data>])  and
	    (if self.right_length = 0
		 then self.right = empty_string
	     else if self.right_length = 1
		 then self.right = <self.last_left.next.data>
	     else if self.right_length = 2
		 then self.right =
		     <self.last_left.next.data> *
		     <self.post_finish.previous.data>
	     else [self.right = 
		 <self.last_left.next.data> *
		 <self.last_left.next.next.data> *
		 ... *
		 <self.post_finish.previous.data>])
    !*/

    local_procedure_body Initialize ()
    {
	//-------- for students to fill in --------    
    }

    local_procedure_body Finalize ()
    {
	//-------- for students to fill in --------    
    }

public:

    standard_concrete_operations (List_Retreat_2);

    procedure_body Add_Right (
	    consumes Item& x
	)
    {
	//-------- for students to fill in --------    
    }

    procedure_body Remove_Right (
	    produces Item& x
	)
    {
	//-------- for students to fill in --------    
    }

    function_body Item& operator [] (
	    preserves Accessor_Position& current
	)
    {
	//-------- for students to fill in --------    
    }

    procedure_body Advance ()
    {
	//-------- for students to fill in --------    
    }

    procedure_body Retreat ()
    {
	//-------- for students to fill in --------    
    }

    procedure_body Move_To_Start ()
    {
	//-------- for students to fill in --------    
    }
    
    procedure_body Move_To_Finish ()
    {
	//-------- for students to fill in --------    
    }
    
    function_body Integer Left_Length ()
    {
	//-------- for students to fill in --------    
    }
   
    function_body Integer Right_Length ()
    {
	//-------- for students to fill in --------    
    }

};

#endif // CT_LIST_RETREAT_2

Last modified: Wed Feb 10 09:14:49 EST 2010