writing program to search address book. fast search time being the biggest priority. professor wants match function to look like
Container<const Person*> matches( std::string prefix ) const;
i am having trouble defining a function of that sort. Also, a second part was added later on to add a hash function to the program. how would i go about writing hash function for a struct of strings. i have attached important parts of the code.
`struct Person
`{
std::string firstName;
std::string lastName;
std::string email;
`};
`class AddressBook
`{
`public:
AddressBook();
void add(Person person);
void match(std::string namesearch);
std::vector<Person> perV;
`};
void AddressBook::match(std::string namesearch)
`{
for (std::vector<Person>::const_iterator itr = perV.begin(); itr < ` ` perV.end(); ++itr)
{
if (strstr(itr->firstName.c_str(), namesearch.c_str()) ||
strstr(itr->lastName.c_str(), namesearch.c_str()))
{
std::cout << itr->firstName << ' ' << itr->lastName
<< std::endl << "Email: " << itr->email << std::endl;
}
}
`}