CIS 11: Data Structures and Algorithms
Project B
Complete Project 8 from Chapter 3 of the text. Directions are on page 142.
- Name your class keyed_bag. You will submit its definition in keyed_bag.h and the implementation in keyed_bag.cpp.
- Set the data type of the bag as
typedef double value_type;
- Include member functions whose prototypes are:
keyed_bag();
void insert(const value_type& entry, int key);
bool erase(int key);
value_type get(int key) const;
size_type size() const;
size_type count(const value_type& target) const;
bool has_key(int key) const;
- If an attempt is made to insert() an entry with a duplicate key, the existing entry should be replaced by one with the new value.
- Create a namespace for your class: cis11.
- Be sure to include appropriate documentation including
- class invariant,
- value semantics,
- description of functionality,
- precondition(s) and
- postcondition(s).
- For some design suggestions follow this link.
- Test your class thouroughly with your own interactive test program similar to the one presented on pp. 133-135 of the text. Name the program keyed_bag_test.cpp.
When you're satisfied with the definition and implementation, submit your work via the CATE form for Project B.
Legend: method/function keyword literal
2007/02/23