// FILE: itemtool.h // PROVIDES: A toolkit of three template functions for manipulating items. // // TEMPLATES FUNCTIONS in the linked list toolkit: // template // Item maximal(Item a, Item b) // Postcondition: Returns the larger of a and b. // Note: Item may be any of the C++ built-in types (int, char, etc.), // or a class with the > operator and a copy constructor. // // template // size_t index_of_maximal(const Item data[ ], SizeType n) // Precondition: data is an array with at least n items, and n>0. // Postcondition: The return value is the index of a maximal item from // data[0] .. data[n-1]. Note: Item may be any of the C++ built-in // types (int, char, etc.), or any class with the > operator defined. // SizeType may be any of the integer or const integer types. // // template // void ordered_insert(Item data[ ], SizeType n, Item& entry) // Precondition: data is a partially filled array containing n items sorted // from small to large. The array size is large enough to hold at least one // more item. // Postcondition: data is a partially filled array containing the n // original items plus the new entry. These items are still sorted from // small to large. Note: Item may be any of the C++ built-in types (int, // char, etc.), or a class with the < operator, an assignment operator, // and a copy constructor. SizeType may be any of the integer or const // integer types. #ifndef ITEMTOOL_H // Prevent duplicate definition #define ITEMTOOL_H // FUNCTIONS for the item toolkit template Item maximal(Item a, Item b); template size_t index_of_maximal(const Item data[ ], SizeType n); template void ordered_insert(Item data[ ], SizeType n, Item entry); #include "itemtool.tem" // Include the implementation #endif