The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 5 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello, could someone help write me a dump function and a copy constructor for my code? Could someone also help write two functions for me?
bool combine(const PeopleList& m1, const PeopleList& m2, PeopleList& result);
When this function returns, result must consist of pairs determined by these rules:
When this function returns, result must contain no elements other than those required by these rules. (You must not assume result is empty when it is passed in to this function; it might not be.)
If there exists a full name that appears in both m1 and m2, but with different corresponding values, then this function returns false; if there is no full name like this, the function returns true. Even if the function returns false, result must be constituted as defined by the above rules.
For example, suppose a PeopleList maps the full name to integers. If m1 consists of these three elements
"Ethel" "Mertz" 456 "Fred" "Mertz" 123 "Lucy" "Ricardo" 789
and m2 consists of
"Lucy" "Ricardo" 789 "Ricky" "Ricardo" 321
then no matter what value it had before, result must end up as a list consisting of
"Ethel" "Mertz" 456 "Fred" "Mertz" 123 "Lucy" "Ricardo" 789 "Ricky" "Ricardo" 321
and combine must return true. If instead, m1 were as before, and m2 consisted of
"Lucy" "Ricardo" 654 "Ricky" "Ricardo" 321
then no matter what value it had before, result must end up as a list consisting of
"Ethel" "Mertz" 456 "Fred" "Mertz" 123 "Ricky" "Ricardo" 321
and combine must return false.
void psearch (const std::string& fsearch, const std::string& lsearch,
const PeopleList& p1, PeopleList& result);
When this function returns, result must contain a copy of all the elements in m1 that match the search terms; it must not contain any other elements. You can wildcard the first name, last name or both by supplying "*". (You must not assume result is empty when it is passed in to this function; it may not be.)
For example, if p consists of the three elements
"Gustavo" "Fring" 57 "Skyler" "White" 45 "Walter" "White" 52
and the following call is made:
psearch("*", "White", p, result)
then no matter what value it had before, result must end up as a PeopleList consisting of
"Skyler" "White" 45 "Walter" "White" 52
If instead, p1 were
"Jane" "Doe" 35 "Marie" "Schrader" 37 "Jane" "Margolis" 27
and the following call is made:
psearch("Jane", "*", p, result)
then no matter what value it had before, result must end up as a list consisting of
"Jane" "Doe" 35 "Jane" "Margolis" 27
Â
and if the following call is made: psearch("*", "*", p, result)
then no matter what value it had before, result must end up being a copy of p
Be sure these functions behave correctly in the face of aliasing: What if m1 and result refer to the same PeopleList, for example?
Please help, I am lost with these two functions.
----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------Tha-----------nk -----------you----------- fo-----------r y-----------our----------- in-----------ter-----------est----------- an-----------d b-----------uyi-----------ng -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll -----------be -----------qui-----------ckl-----------y