Question: Part 1 : Implementation ### Entry Class Implementation Create an ` Entry ` class to store key - value pairs. #### Entry.h - Member Variables

Part 1: Implementation
### Entry Class Implementation
Create an `Entry` class to store key-value pairs.
#### Entry.h
- Member Variables (Private):
- K _key;
- V _value; /.
- Member Functions (Public):
- Entry(K, V);
- ~Entry();
- K getK();
- V getV(); /
- void setK(K);
- void setV(V);
### DNodeG Class Implementation
Develop a `DNodeG` class to represent nodes in the doubly linked list used in
`NodeDictionaryG`.
#### DNodeG.h
- Member Variables (Public):
- Entry elm;
- DNodeG* next;
- DNodeG* prev;
- static int activeNodes;
- Member Functions (Public):
- DNodeG(const Entry& = Entry(), DNodeG* p = nullptr, DNodeG* n = nullptr);
- ~DNodeG();
### IteratorG Class Implementation
Develop an `IteratorG` class template to allow traversal of nodes within the
`NodeDictionaryG`. This iterator provides functionality to navigate through
elements in the doubly linked list.
#### IteratorG.h
- Member Variables (Private):
- DNodeG* v;
- Member Functions (Public):
- const V& operator*();
- bool operator==(const IteratorG& p) const;
- bool operator!=(const IteratorG& p) const;
- IteratorG& operator++();
- IteratorG& operator--();
- IteratorG(DNodeG* u);
- const Entry& entry();
### Range Class Implementation
Implement the `Range` class to represent a range of iterators. This class defines
the boundaries of a range, consisting of a beginning and an end iterator.
#### Range.h
- Member Variables (Private):
- IteratorG b; // Beginning of the range.
- IteratorG e; // End of the range.
- Member Functions (Public):
// Constructor to initialize the range with given iterators.
- Range(const IteratorG& b, const IteratorG& e);
- IteratorG& getB(); // Returns the beginning iterator.
- IteratorG& getE(); // Returns the end iterator.
### NodeDictionaryG Class Implementation
Implement the `NodeDictionaryG` class to define the dictionary operations using
a doubly linked list with dummy nodes.
#### NodeDictionaryG.h
- Member Variables (Private):
- int uKeys; // Current number of unique keys in the dictionary.
- int n; // Total number of entries in the dictionary.
- DNodeG* header; // Sentinel node at the start of the list.
- DNodeG* trailer; // Sentinel node at the end of the list.
- Member Functions (Public):
- NodeDictionaryG(); // Constructor to initialize the dictionary with header and trailer nodes.
- ~NodeDictionaryG(); // Destructor to clean up memory.
- int size() const; // Returns the total number of entries.
- int uniqueKeys() const; // Returns the number of unique keys.
- bool empty() const; // Checks if the dictionary is empty.
- IteratorG begin() const; // Returns an iterator pointing to the first entry.
- IteratorG end() const; // Returnsan iterator pointing past the last entry.
- IteratorG find(const K& k) const; // Finds the first entry with the given key
// Inserts a key-value pair.
//If there are entry with key == k the new entry will be inserted after the last entry with key = k.
- IteratorG put(const K& k, const V& v);
- void erase(const K& k); // Removes the first entry with the given key.
- void erase(const IteratorG& p);// Removes the entry at the given iterator.
- void erase(Range& r); // Removes all entries in the specified range.
- Range findAll(const K& k); // Returns a range of entries with the given key.
- void print(); // Prints all entries in the dictionary.
- void print(Range& r); // Prints all entries in the specified range.
### EnglishDictionary Class Implementation
Implement the `EnglishDictionary` class using the `NodeDictionaryG` class operations.
#### EnglishDictionary.h (Header File)
- Member Variables (Private):
- string name; // Name of the dictionary.
- NodeDictionaryG dictionary; // Stores the words and their definitions.
- Member Functions (Public):
- EnglishDictionary(string); // Constructor
- ~EnglishDictionary(); // Destructor
- int words() const; // Returns the total number of words in the dictionary.
- int uniqueWords() const; // Returns the number of unique words.
- bool empty() const; // Checks if the dictionary is empty.
- void add(Entry); // Adds a new word and its definition.
- void deleteFirst(string); // Deletes the first definition of a word.
- void deleteWord(string); // Deletes all definitions of a word.
- void printDictionary(bool); //Should be implemented as an recursive function. Prints all entries in the dictionary (true = forward, false = reverse).
- void printDictionary(string); // Prints all definitions for a given word.
- Entry find(string); // Finds the first entry for a given word.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!