CIS 11: Data Structures and Algorithms
Project D
Complete Project 12e from Chapter 5 of the text. Directions are on page 277.
- Name your class keyed_bag3. You will submit its definition in keyed_bag3.h and the implementation in keyed_bag3.cpp.
- Use the node class interface file available here instead of the one from the book. The linked list toolkit from Chapter 5 of the text will work unmodified. Copy all of the source files into the same directory as the rest of your project. Be careful about using appropriate namespaces. You will not submit the authors' files.
- Include member functions whose prototypes are:
keyed_bag3();
keyed_bag3(const keyed_bag3& source);
~keyed_bag3();
keyed_bag3& operator =(const keyed_bag3& source);
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;
- In order to provide standard behavior, be sure that the assignment operator returns *this.
- 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.
- Do not create a namespace for your class.
- Test your class thoroughly with your own interactive test program similar to the one presented on pp. 133-135 of the text. You will not submit the test program.
When you're satisfied with the definition and implementation, submit your work via the CATE form for Project D.
Legend: method/function keyword literal
2007/02/23