Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef LECTURE_H_INCLUDED
- #define LECTURE_H_INCLUDED
- #include "Resource.h"
- #include "ResourceType.h"
- #include <set>
- #include <vector>
- namespace SoftUni{
- class Lecture{
- std::map<ResourceType,int> allTypes;
- std::set<Resource> allLectures;
- public:
- std::set<Resource>& operator << (const Resource& c){
- std::set<Resource>::iterator itr;
- itr = allLectures.find(c);
- if(itr!=allLectures.end()){
- allLectures.erase(itr);
- }
- allLectures.insert(c);
- allTypes[c.getType()]++;
- return allLectures;
- }
- int operator[](const ResourceType& rt){
- std::map<ResourceType,int>::iterator itr;
- itr=allTypes.find(rt);
- return itr->second;
- }
- std::set<Resource>::iterator begin() const {
- return allLectures.begin();
- }
- std::set<Resource>::iterator end() const {
- return allLectures.end();
- }
- friend std::vector<ResourceType>& operator<<(std::vector<ResourceType>& v, const Lecture& lecture);
- };
- std::vector<ResourceType>& operator<<(std::vector<ResourceType>& v, const Lecture& lecture){
- for(auto& r : lecture.allLectures){
- v.push_back(r.getType());
- }
- return v;
- }
- }
- #endif // LECTURE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement