Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c + + please help me complete this dict.h #pragma once #include #include #include #include treeClass.hpp #include pair.hpp template class Dictionary {

In c++ please help me complete this
dict.h
#pragma once
#include
#include
#include
#include "treeClass.hpp"
#include "pair.hpp"
template
class Dictionary {
private:
Tree> dictTree;
public:
Dictionary()= default;
bool empty(){
return dictTree.isEmpty();
}
size_t size(){
return dictTree.size();
}
ValueType& get(KeyType key)
{
}
void set(KeyType key, ValueType value){
Pair thePair = MakePair(key, value);
bool inTree = dictTree(thePair, thePair);
if (inTree){
return thePair.second;
}
else {
throw std::out_of_range("Item does not exist in Dictionary");
}
}
void insert(KeyType key, ValueType value){
BST b;
Pair newEntry = MakePair(key, value);
dictTree.insert(newEntry);
b.Insert(key, value);
}
list getKeys(){
list listKey;
return listKey;
}
list getValues()
{
list listValue;
return listValue;
}
ValueType& at(const KeyType item){
ValueType theValue;
Pair thePair = MakePair(item, theValue);
bool inTree = dictTree(thePair, thePair);
if (inTree){
return thePair.second;
}
else {
throw std::out_of_range("Item does not exist in Dictionary");
}
}
ValueType& operator[](const KeyType& key){
return at(key);
}
ValueType& operator[](const KeyType item){
return at(item);
}
};
pair.hpp
#pragma once
template
class Pair {
public:
KeyType first;
ValueType second;
Pair()= delete;
Pair(KeyType x, ValueType y) : first(x), second(y){}
bool operator(const Pair rhs) const {
bool meetsCriteria = false;
if (this->first rhs.first){
meetsCriteria = true;
}
return meetsCriteria;
}
bool operator>(const Pair rhs) const {
bool meetsCriteria = false;
if (this->first > rhs.first){
meetsCriteria = true;
}
return meetsCriteria;
}
bool operator==(const Pair rhs) const {
bool meetsCriteria = false;
if (this->first == rhs.first){
meetsCriteria = true;
}
return meetsCriteria;
}
};
template
Pair& MakePair(KeyType first, ValueType second){
Pair* newPair = new Pair(first, second);
return *newPair;
}
template
class Pear
{
public:
T1 key;
T2 value;
};
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions