diff options
| author | MDBijman <matthijs@bijman.org> | 2017-01-24 12:15:26 +0100 |
|---|---|---|
| committer | MDBijman <matthijs@bijman.org> | 2017-01-24 12:15:26 +0100 |
| commit | 070ce923574dcc57435cb3fb2dfe86b6a38cd249 (patch) | |
| tree | ffd69a842ac4ad22aaf7161f923b9f0b47c7147a /Simulator/include/simulation/history/History.h | |
Initial code commit with organized dependencies
Diffstat (limited to 'Simulator/include/simulation/history/History.h')
| -rw-r--r-- | Simulator/include/simulation/history/History.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Simulator/include/simulation/history/History.h b/Simulator/include/simulation/history/History.h new file mode 100644 index 00000000..f1d826eb --- /dev/null +++ b/Simulator/include/simulation/history/History.h @@ -0,0 +1,43 @@ +#pragma once +#include <stdint.h> +#include <map> + +namespace Simulation { + template<typename Type> + class History { + public: + void addSnapshotAtTick(uint32_t tick, Type snapshot) + { + history.insert(std::make_pair(tick, snapshot)); + } + + const auto& snapshotsAtTick(uint32_t tick) + { + return history.equal_range(tick); + } + + typename std::unordered_map<uint32_t, Type>::const_iterator begin() + { + return history.begin(); + } + + typename std::unordered_map<uint32_t, Type>::const_iterator end() + { + return history.end(); + } + + void clear() + { + history.clear(); + } + + size_t size() + { + return history.size(); + } + + private: + // Maps ticks to histories of workloads + std::unordered_multimap<uint32_t, Type> history; + }; +}
\ No newline at end of file |
