Constraints:
For example, if your input is:
AddStudent 48 Smiley AddStudent 35 Brad AddStudent 55 Nancy AddStudent 17 Nancy JoinClub 55 tennis JoinClub 55 bridge JoinClub 48 tennis JoinClub 17 tennis JoinClub 35 chess JoinClub 48 chessthen the tennis club would have {Nancy, Smiley, Nancy} as members, the bridge club would have {Nancy} as a member, and the chess club would have {Brad, Smiley} as members.
The data structures for the program are as follows:
class Person { public: int id; string name; // initializes the id and name fields Person(int personId, string personName); }; class Club { public: string name; list<Person *> members; // the list of pointers to students' Person objects // initializes the name field and makes members an empty list Club(string n); }; typedef vector<Club *> Bucket; class HashTable { // uses separate chaining public: HashTable(int tableSize); // sets the table to the correct size void Insert(string clubName, Person *student); // described below void PrintClubs(); // prints the bucket index for each club, the club's // name, and the club's members protected: vector<Bucket> table; // stores pointers to Club objects unsigned int Hash(string &key); // returns a random number }; // These two variables are declared in main() HashTable *clubs; // a hash table of clubs map<int, Person *> students; // a map of students |
The two parts of the program you need to write are as follows:
Constraints:
Handy Methods From The STL's Map API