// ********************************************************* // Header file ListA.h for the ADT list. // Array-based implementation. // ********************************************************* const int MAX_LIST = maximum-size-of-list; typedef desired-type-of-list-item listItemType; class listClass { public: listClass(); // default constructor // destructor is supplied by compiler // list operations: bool ListIsEmpty() const; // Determines whether a list is empty. // Precondition: None. // Postcondition: Returns true if the list is empty, // otherwise returns false. int ListLength() const; // Determines the length of a list. // Precondition: None. // Postcondition: Returns the number of items // that are currently in the list. void ListInsert(int NewPosition, listItemType NewItem, bool& Success); // Inserts an item into a list. // Precondition: NewPosition indicates where the // insertion should occur. NewItem is the item to be // inserted. // Postcondition: If insertion was successful, NewItem is // at position NewPosition in the list, other items are // renumbered accordingly, and Success is true; // otherwise Success is false. // Note: Insertion will not be successful if // NewPosition < 1 or > ListLength()+1. void ListDelete(int Position, bool& Success); // Deletes an item from a list. // Precondition: Position indicates where the deletion // should occur. // Postcondition: If 1 <= Position <= ListLength(), // the item at position Position in the list is // deleted, other items are renumbered accordingly, // and Success is true; otherwise Success is false. void ListRetrieve(int Position, listItemType& DataItem, bool& Success) const; // Retrieves a list item by position number. // Precondition: Position is the number of the item to // be retrieved. // Postcondition: If 1 <= Position <= ListLength(), // DataItem is the value of the desired item and // Success is true; otherwise Success is false. private: listItemType Items[MAX_LIST]; // array of list items int Size; // number of items in list int Index(int Position) const; // Converts the position of an item in a list to the // correct index within its array representation. }; // end class // End of header file.