|
|
|
|
|
|
|
FIGURE 18-6 Specification of the OrdList Class |
|
|
|
|
|
|
|
|
//******************************************************************
// SPECIFICATION FILE (ordlist.h)
// This file gives the specification of an ordered list
// abstract data type. The list components are in ascending order
//******************************************************************
#include "bool.h"
typedef int ComponentType;
struct NodeType; // Forward declaration
// (Complete declaration is
// hidden in implementation file)
class OrdList
{
public:
Boolean 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:
// List components are in ascending order
// && item < first component in list
// Postcondition:
// item is inserted as first component in list
// && List components are in ascending order
void Insert ( /* in */ ComponentType item );
// Precondition:
// List components are in ascending order
// && item is assigned
// Postcondition:
// item is inserted in list
// && List components are in ascending order
void DeleteTop( /* out */ ComponentType& item );
// Precondition:
// List is not empty
// && List components are in ascending order
// Postcondition:
// item == first component in list at entry
// && item is no longer in list
// && List components are in ascending order |
|
|
|
|
|