-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchedule.h
More file actions
73 lines (68 loc) · 1.93 KB
/
Schedule.h
File metadata and controls
73 lines (68 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SCHEDULE_H
#define SCHEDULE_H
#include <string>
#include <vector>
#include <iosfwd>
#include<algorithm>
#include<iterator>
#include "Event.h"
class Schedule {
public:
class iterator;
class const_iterator;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
Schedule();
explicit Schedule(const std::string& filename);
explicit Schedule(std::istream& is);
Schedule(const Schedule& other);
Schedule& operator=(const Schedule& other);
~Schedule();
void read(std::istream& is);
void clear();
std::size_t size() const;
bool empty() const;
const Event& operator[](std::size_t index) const;
void sort();
friend std::ostream& operator<<(std::ostream& os, const Schedule& schedule);
private:
std::vector<Event> events_;
};
class Schedule::iterator {
public:
iterator();
iterator(const iterator& other);
iterator(Schedule* schedule, std::size_t index);
iterator& operator++();
iterator operator++(int);
iterator& operator--();
iterator operator--(int);
const Event& operator*() const;
bool operator==(const iterator& other) const;
bool operator!=(const iterator& other) const;
private:
Schedule* schedule_;
std::size_t index_;
};
class Schedule::const_iterator {
public:
const_iterator();
const_iterator(const const_iterator& other);
const_iterator(const Schedule* schedule, std::size_t index);
const_iterator& operator++();
const_iterator operator++(int);
const_iterator& operator--();
const_iterator operator--(int);
const Event& operator*() const;
bool operator==(const const_iterator& other) const;
bool operator!=(const const_iterator& other) const;
operator iterator() const;
private:
const Schedule* schedule_;
std::size_t index_;
};
// Output operator for Schedule
std::ostream& operator<<(std::ostream& os, const Schedule& schedule);
#endif