Assignment 2
Imagine that you are developing an address book application. The address book stores Person records. The address book allows quick look up of matching Person records when the user types in the initial part of a person’s first or last name.
The address book can be considered similar to the auto complete service in Lab 3. Develop a prototype service that will satisfy the requirements of a hypothetical address book application.
The expected features are as follows:
- The service will use a Person structure instead of strings as the data of interest.
- The service will find matching person instances by first or last name (beginning of first/last name as expected with Tries).
- The service implementation will use only a single trie, not multiple trie’s to support looking up by either first or last name.
- Only a single instance of a Person will be stored (no duplication of Person instances).
- Person instances should not be copied when returning matching person instances.
- Include unit test suite that tests matching person instances by first name, last name, as well as first or last name.
namespace csc280
{
struct Person
{
const std::string firstName;
const std::string lastName;
const std::string email;
};
inline bool operator==( const Person& lhs, const Person& rhs )
{
return lhs.firstName == rhs.firstName &&
lhs.lastName == rhs.lastName &&
lhs.email == rhs.email;
}
class AddressBook
{
public:
void add( Person person );
Container<const Person*> matches( std::string prefix ) const;
};
}