//******************************************************************
// SPECIFICATION FILE (slist2.h)
// This file gives the specification of a sorted list abstract data
// type. The list components are maintained in ascending order of
// value
//******************************************************************
typedef int ComponentType; // Type of each component
// (a simple type or the string type)
struct NodeType; // Forward declaration
// (Complete declaration is
// hidden in implementation file)
class SortedList2
{
public:
bool IsEmpty() const;
// Postcondition:
// Function value == true, if list is empty
// == false, otherwise
void Print() const;
// Postcondition:
// All components (if any) in list have been output
void InsertTop( /* in */ ComponentType item );
// Precondition:
// item < first component in list
// Postcondition:
// item is first component in list
// && List components are in ascending order
void Insert( /* in */ ComponentType item );
// Precondition:
// item is assigned
// Postcondition:
// item is in list
// && List components are in ascending order
void DeleteTop( /* out */ ComponentType& item );
// Precondition:
// NOT IsEmpty()
// Postcondition:
// item == first component in list at entry
// && item is no longer in list
// && List components are in ascending order
void Delete( /* in */ ComponentType item );
// Precondition:
// item is somewhere in list
// Postcondition:
// First occurrence of item is no longer in list
// && List components are in ascending order
SortedList2();
// Constructor
// Postcondition:
// Empty list is created
SortedList2( const SortedList2& otherList );
// Copy-constructor
// Postcondition:
// List is created as a duplicate of otherList
~SortedList2();
// Destructor
// Postcondition:
// List is destroyed
private:
NodeType* head;
};