Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Very lost on where to start with this, and guidance or help would be very appreciated! proj10_mapset.h #ifndef MAP_SET #define MAP_SET #include using std::ostream; #include
Very lost on where to start with this, and guidance or help would be very appreciated!
proj10_mapset.h
#ifndef MAP_SET #define MAP_SET #includeusing std::ostream; #include using std::string; #include using std::vector; #include using std::pair; #include using std::initializer_list; #include using std::sort; using std::lower_bound; #include using std::ostringstream; // // Node // template struct Node { K first; V second; Node() = default; Node(K,V); bool operator Node ::Node(K key, V value){ } template bool Node ::operator bool Node ::operator==(const Node &n) const{ } // // MapSet // template class MapSet{ private: Node * ary_; size_t last_; size_t capacity_; Node * find_key(K); void grow (); public: MapSet(int sz = 2); MapSet(initializer_list >); MapSet (const MapSet&); MapSet operator=(MapSet); ~MapSet(); size_t size(); bool remove (K); bool add(Node ); Node get(K); bool update(K,V); int compare(MapSet&); MapSet mapset_union (MapSet&); MapSet mapset_intersection(MapSet&); friend ostream& operator MapSet ::MapSet(int capacity){ } template MapSet ::MapSet(initializer_list > il){ } template MapSet ::MapSet(const MapSet &ms){ } // copy and swap template MapSet MapSet ::operator=(MapSet ms){ } template MapSet ::~MapSet(){ } template size_t MapSet ::size(){ } template void MapSet ::grow(){ } template Node * MapSet ::find_key(K key){ } template bool MapSet ::add(Node n){ } template bool MapSet ::remove(K key){ } template Node MapSet ::get(K key){ } template bool MapSet ::update(K key, V value){ } template int MapSet ::compare(MapSet &ms){ } template MapSet MapSet ::mapset_union(MapSet &ms){ } template MapSet MapSet ::mapset_intersection(MapSet &ms){ } #endif
proj10_main.cpp
#includeusing std::cout; using std::endl; using std::boolalpha; #include using std::string; #include using std::ostringstream; #include "proj10_mapset.h" int main (){ cout n1("bill", 2); cout n2("fred", 3); cout ms({ {"bill", 1}, {"fred", 2}, {"alan", 3}, {"bob", 4} }); MapSet ms_copy(ms); cout mtest({ {"z",1},{"e",2},{"x",3}, {"q", 4} }); cout ntest; ntest = mtest.get("m"); cout ntest2 = mtest.get("q"); cout msl1( { {4, "bob"}, {1, "bill"}, {3, "alan"}, {2, "fred"} } ); cout msl1_copy(msl1); cout Programming Project #10 Assignment Overview In this assignment you will continuc your practice crcating a combination data structurc, MapSet, which combines a map and a set. We change the specifications so that you cannot use a STL vector nor pair (as well as not use map or set or the sort algorithm). You will update your class to use dynamic arrays. It is duc 04/16, Monday, before midnight on Mimir. Project is worth 60 points (6% of your overall grade) Background We are going to stay with the MapSet problem but update its implementation. We are going to stop using vectors and pairs and do the work ourselves with an underlying dynamic array. We will also template to the class to work with different types We do this as a better way to get familiar with the underlying problem of templated classes and dynamic arrays The specs of the MapSet should be familiar to you now, so it is a matter of changing the implementation. The focus will be on this implementation Details As this is a templated class you can only write a header file to solve the problem. Thus, we will provide a proto- header file, proj10_mapset.h, which you will fill in. In the specifications below, we will focus on what is different first for this vs. the previous MapSet, then update the rest of the already familiar set of methods. Class Node Since we cannot use the STL pair, we are going to have to write our own struct called Node. This will take the place of the pair from the STL. Here is the header part of Node template struct Node K first V second; Node )default Node (K, V); bool operator struct Node K first V second; Node )default Node (K, V); bool operator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started