#ifndef __VENUES_HPP__ #define __VENUES_HPP__ #include #include #include using std::unordered_map; using std::string; using std::vector; namespace cs427_527 { /** * A history of venues played at by a single team. */ class TeamVenues { public: using const_iterator = vector::const_iterator; /** * Adds the given venue to the end of this record. * * @param venue a string */ void addGame(const string& venue); /** * Returns a read-only iterator over the venues in this record. * Each venue will be iterated over exactly once. The returned * iterator may be invalidated by addGame. * * @return an iterator over the venues */ const_iterator begin() const; /** * Returns a read-only iterator past the end of the venues in * this record. The returned iterator may be invalidated by addGame. * * @return an iterator past the end of the venues */ const_iterator end() const; /** * Returns the indices of the calls to addGame that added the * given venue to this record. The first call to addGame is * considered index 1. */ vector games(const string& venue) const; private: /** * The number of times a venue appears in this record. */ unordered_map counts; /** * A list of the distinct venues in this record, in the order they * were added. */ vector distinct; /** * The venues in this record in the order they were added. */ vector sequence; }; /** * A history of venues played at by a collection of teams. */ class VenueHistory { public: using const_iterator = unordered_map::const_iterator; /** * Records that the given teams played at the given venue. * * @param team1 a string * @param team2 a string * @param venue a string */ void addGame(const string& team1, const string&team2, const string& venue); /** * Returns a read-only iterator over the pairs of teams and * venue records in this history. The returned iterator may be * invalidated by addGame. * * @return an iterator over the venues */ const_iterator begin() const; /** * Returns a read-only iterator past the end of (team, record) pairs * in this history. The returned iterator may be invalidated by addGame. * * @return an iterator past the end of the venues */ const_iterator end() const; private: unordered_map venues; }; } #endif