You are given the Dictionary code below; template class ArrayDictionary: public Dictionary Interface { private: static...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are given the Dictionary code below; template <class KeyType, class ItemType> class ArrayDictionary: public Dictionary Interface<KeyType, Item Type> { private: static const int DEFAULT_CAPACITY = 21; // Small capacity to test for // a full dictionary std::unique_ptr<Entry<KeyType, ItemType> [] > items; // Array of dictionary entries // Current count of dictionary items // Maximum capacity of the dictionary int itemCount; int maxItems; void destroy Dictionary(); int findEntryIndex(int firstIndex, int lastIndex, const KeyType& searchkey) const; public: ArrayDictionary(); ArrayDictionary (int maxNumberOfEntries); ArrayDictionary (const ArrayDictionary<KeyType, ItemType>& dict); virtual ~ArrayDictionary (); bool isEmpty() const; int getNumberOfItems() const; bool add(const KeyType& searchkey, const ItemType& newItem); bool remove (const KeyType& searchkey); void clear(); ItemType getItem(const KeyType& searchkey) const throw (NotFoundException); bool contains (const KeyType& searchkey) const; /** Traverses the items in this dictionary in sorted search-key order and calls a given client function once for each item. */ void traverse(void visit(ItemType&)) const; }; //end ArrayDictionary Write a "REPLACE" method that replaces the data value associated with a given search key in the dictionary. The "Replace" method will have the definition and the declaration parts together, which means the body part. Important notes with "REPLACE" method; • Use only the variables and the methods stated above to write the code, no other var or method is acceptable. • The code is written due to "ArrayDictionary" implementation of the dictionary file. • Keep in mind that "Replace" method does not alter the search key, just the item is to be changed. You are given the Dictionary code below; template <class KeyType, class ItemType> class ArrayDictionary: public Dictionary Interface<KeyType, Item Type> { private: static const int DEFAULT_CAPACITY = 21; // Small capacity to test for // a full dictionary std::unique_ptr<Entry<KeyType, ItemType> [] > items; // Array of dictionary entries // Current count of dictionary items // Maximum capacity of the dictionary int itemCount; int maxItems; void destroy Dictionary(); int findEntryIndex(int firstIndex, int lastIndex, const KeyType& searchkey) const; public: ArrayDictionary(); ArrayDictionary (int maxNumberOfEntries); ArrayDictionary (const ArrayDictionary<KeyType, ItemType>& dict); virtual ~ArrayDictionary (); bool isEmpty() const; int getNumberOfItems() const; bool add(const KeyType& searchkey, const ItemType& newItem); bool remove (const KeyType& searchkey); void clear(); ItemType getItem(const KeyType& searchkey) const throw (NotFoundException); bool contains (const KeyType& searchkey) const; /** Traverses the items in this dictionary in sorted search-key order and calls a given client function once for each item. */ void traverse(void visit(ItemType&)) const; }; //end ArrayDictionary Write a "REPLACE" method that replaces the data value associated with a given search key in the dictionary. The "Replace" method will have the definition and the declaration parts together, which means the body part. Important notes with "REPLACE" method; • Use only the variables and the methods stated above to write the code, no other var or method is acceptable. • The code is written due to "ArrayDictionary" implementation of the dictionary file. • Keep in mind that "Replace" method does not alter the search key, just the item is to be changed.
Expert Answer:
Answer rating: 100% (QA)
c template bool ArrayDictionaryreplaceconst KeyType searchKey const ItemType newItem Find the index of the entry with the given search key int entryIndex findEntryIndex0 itemCount 1 searchKey If the e... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Describe a favorite work of visual art and includea picture of it in your post. Your selection may come from the entire range of visual arts, anything from a famous painting in a museum to an iconic...
-
(1) based on the loan terms in the box (including prepayment/default/severity assumption) (2) Calculate the weighted avg life ("WAL") (3) Calculate the price using a 6% yield (4) Calculate the...
-
When is inflation an important issue in conducting case analysis? Why bother?
-
1. Specials An ice cream parlor offers a special consisting of three scoops of ice cream chosen from 16 different flavors. Duplication of flavors is allowed. For instance, one possibility is two...
-
Define the following concepts so as to generalize naturally the definitions in the text given for dimensions 0. 1, 2, and 3. a. An oriented n-simplex b. The boundary of an oriented n-simplex c. A...
-
One way to double the capacitance of a parallel-plate capacitor is to reduce the plate separation distance by a factor of 2. Doubling the capacitance of a spherical capacitor is a bit more complex,...
-
Orlando and Diego Universities offer executive training courses to corporate clients. Orlando pays its instructors $4,600 per course taught. Diego pays its instructors $230 per student enrolled in...
-
16. A signal containing multiple frequencies is shown in figure A. It is passed through 2 different filters and then outputs are shown in figure B & C. M (A) S (B) sha (C) (a) B corresponds to low...
-
Computer Project Exercises In developing the exercises, trade-offs had to be made to enrich the learning experience. One of the major problems students initially encounter is data and detail...
-
Write a paper on a research topic relating to Data Management.
-
A social allowance paid under the Social Development Act, a handicap benefit paid under the Assured Income for the Severely Handicapped Act, a widow's pension paid under the Widows' Pension Act, if...
-
In 2000 or more words Discuss all ethical issues/questions related to the topic Gangs in America and the strategies used to address the problem in the United States. Hint* 1. Include what are the...
-
Please answer each of following questions in about 100 wrds. (60 points) What is a restrictive covenant in employment and when it could be enforceable? (Mention in your answers at least three...
-
Consider 3-month options with premium Strike 35 Call premium 40 45 and 2. the write and options: draw premium). (ii) Call (iii) 6.13 2.78 0.97 effective written put donn and the (i). Straddle : buy...
-
For the below graph, draw tree and apply uniform cost search to find the goal? Explain all steps and fringe variable and also give the time and space complexity. (10) 5 is the starting state G is the...
-
Paula Angelillis operates the Hard-to-Find Auto Parts Store. Much of her business is by mail. The following transactions related to sales and cash receipts occurred during June: 1 Received $300 from...
-
Revol Industries manufactures plastic bottles for the food industry. On average, Revol pays $76 per ton for its plastics. Revol's waste-disposal company has increased its waste-disposal charge to $57...
-
Which operators cannot be overloaded?
-
Write a program that asks the user to type in numbers. After each entry, the program should report the cumulative sum of the entries to date. The program should terminate when the user enters 0.
-
Give at least three examples of convenience advantages that a vector object has over an ordinary array.
-
Suppose a bond is taxable for both federal and state purposes. Let Rb = the BTROR on the bond, tfed = the federal tax rate, and tst = the state tax rate. Determine the ATROR (i.e., after federal and...
-
Under what conditions are the Exempt Model and Pension Model equivalent? Under what conditions would one model perform better than the other? How does the \($6,500\) limitation on deductible and Roth...
-
Consider three taxpayers who are in the following tax brackets: Alice 25% Brad 35% Camille 40%
Study smarter with the SolutionInn App