Advertisement
Guest User

Lecture.h

a guest
Dec 26th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #ifndef LECTURE_H_INCLUDED
  2. #define LECTURE_H_INCLUDED
  3. #include "Resource.h"
  4. #include "ResourceType.h"
  5. #include <set>
  6. #include <vector>
  7. namespace SoftUni{
  8.  
  9. class Lecture{
  10. std::map<ResourceType,int> allTypes;
  11. std::set<Resource> allLectures;
  12.  
  13. public:
  14.  
  15. std::set<Resource>& operator << (const Resource& c){
  16. std::set<Resource>::iterator itr;
  17.  
  18. itr = allLectures.find(c);
  19. if(itr!=allLectures.end()){
  20. allLectures.erase(itr);
  21. }
  22. allLectures.insert(c);
  23. allTypes[c.getType()]++;
  24.  
  25. return allLectures;
  26.  
  27. }
  28.  
  29. int operator[](const ResourceType& rt){
  30.  
  31. std::map<ResourceType,int>::iterator itr;
  32. itr=allTypes.find(rt);
  33.  
  34. return itr->second;
  35. }
  36. std::set<Resource>::iterator begin() const {
  37. return allLectures.begin();
  38. }
  39. std::set<Resource>::iterator end() const {
  40. return allLectures.end();
  41. }
  42.  
  43. friend std::vector<ResourceType>& operator<<(std::vector<ResourceType>& v, const Lecture& lecture);
  44. };
  45. std::vector<ResourceType>& operator<<(std::vector<ResourceType>& v, const Lecture& lecture){
  46. for(auto& r : lecture.allLectures){
  47. v.push_back(r.getType());
  48.  
  49. }
  50. return v;
  51. }
  52.  
  53.  
  54. }
  55. #endif // LECTURE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement