Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Scheduler.h"
- namespace academia{
- SchedulingItem::SchedulingItem(int course,int teacher,int room,int time, int year_){
- course_id = course;
- teacher_id = teacher;
- room_id = room;
- time_slot = time;
- year = year_;
- }
- int SchedulingItem::CourseId() const{
- return course_id;
- }
- int SchedulingItem::TeacherId() const{
- return teacher_id;
- }
- int SchedulingItem::RoomId() const{
- return room_id;
- }
- int SchedulingItem::TimeSlot() const{
- return time_slot;
- }
- int SchedulingItem::Year() const{
- return year;
- }
- Schedule Schedule::OfTeacher(int teacher_id) const {
- std::vector<SchedulingItem>temp;
- std::copy_if(schedule.begin(),schedule.end(),temp.begin(),[teacher_id](const SchedulingItem &element)
- {return teacher_id == element.TeacherId();});
- Schedule temp_schedule;
- temp_schedule.schedule = temp;
- return temp_schedule;
- }
- Schedule Schedule::OfRoom(int room_id) const {
- std::vector<SchedulingItem>temp;
- std::copy_if(schedule.begin(),schedule.end(),temp.begin(),[room_id](const SchedulingItem &element)
- {return room_id == element.RoomId();});
- Schedule temp_schedule;
- temp_schedule.schedule = temp;
- return temp_schedule;
- }
- Schedule Schedule::OfYear(int year) const {
- std::vector<SchedulingItem>temp;
- std::copy_if(schedule.begin(),schedule.end(),temp.begin(),[year](const SchedulingItem &element)
- {return year == element.Year();});
- Schedule temp_schedule;
- temp_schedule.schedule = temp;
- return temp_schedule;
- }
- std::vector<int> Schedule::AvailableTimeSlots(int n_time_slots) const {
- std::vector<int> temp;
- for(auto &i : schedule){
- if(i.time_slot <= n_time_slots){
- temp.push_back(i.time_slot);
- }
- }
- std::sort(temp.begin(),temp.end());
- auto temp1 = std::unique(temp.begin(),temp.end());
- temp.erase(temp1,temp.end());
- return temp;
- }
- void Schedule::InsertScheduleItem(const SchedulingItem &item) {
- schedule.push_back(item);
- }
- size_t Schedule::Size() const {
- return schedule.size();
- }
- SchedulingItem Schedule::operator[](int number) const{
- return schedule[number];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement