summaryrefslogtreecommitdiff
path: root/Simulator/include/simulation/history/History.h
blob: f1d826ebdf25bea04361f6eaffae8acfe0271791 (plain)
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
#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;
	};
}