25 using Block = vector<unique_ptr<T>>;
26 using Agenda = list<unique_ptr<Block>>;
30 if (days >= m_agenda.size()) {
32 uint new_blocks = (days + 1) - m_agenda.size();
33 for (
unsigned int i = 0; i < new_blocks; i++) {
35 m_agenda.emplace_back(block);
38 block = next(m_agenda.begin(), days)->
get();
44 if (days >= m_agenda.size()) {
48 return next(m_agenda.cbegin(), days)->
get();
56 void add(
unsigned int days, T thing) {
57 Block* block = getModifiableDay(days);
58 T* new_thing =
new T(thing);
59 block->emplace_back(new_thing);
63 if (not m_agenda.empty()) m_agenda.pop_front();
66 unsigned int days()
const {
67 return m_agenda.size();
78 unsigned int size()
const {
79 unsigned int size = 0;
81 for (
auto& block: m_agenda) {
82 size += block->size();
list< unique_ptr< Block >> Agenda
You can see this class as a kind of planner that stores events in the near future.
Time Dependent Person DataType.
unsigned int days() const
const Block * getDay(unsigned int days) const
void add(unsigned int days, T thing)
vector< unique_ptr< stride::Traveller< stride::Simulator::stride::Person > >> Block
const Agenda & getAgenda() const
unsigned int size() const
Block * getModifiableDay(unsigned int days)
const Block * today() const