Skip to content

Commit 99a702a

Browse files
committed
Replace vector with array
1 parent 4fd49d4 commit 99a702a

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/dsm/dsm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
static constexpr uint8_t DSM_VERSION_MAJOR = 2;
88
static constexpr uint8_t DSM_VERSION_MINOR = 6;
9-
static constexpr uint8_t DSM_VERSION_PATCH = 8;
9+
static constexpr uint8_t DSM_VERSION_PATCH = 9;
1010

1111
static auto const DSM_VERSION =
1212
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH);

src/dsm/headers/TrafficLight.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace dsm {
5151

5252
class TrafficLight : public Intersection {
5353
private:
54-
std::unordered_map<Id, std::vector<TrafficLightCycle>> m_cycles;
54+
std::unordered_map<Id, std::array<TrafficLightCycle, 3>> m_cycles;
5555
Delay m_cycleTime; // The total time of a red-green cycle
5656
Delay m_counter;
5757

@@ -104,8 +104,9 @@ namespace dsm {
104104
/// @param cycle The traffic light cycle
105105
void setCycle(Id const streetId, Direction direction, TrafficLightCycle const& cycle);
106106
/// @brief Set the traffic light's cycles
107-
/// @param cycles std::unordered_map<Id, std::vector<TrafficLightCycle>> The traffic light's cycles
108-
inline void setCycles(std::unordered_map<Id, std::vector<TrafficLightCycle>> cycles) {
107+
/// @param cycles std::unordered_map<Id, std::array<TrafficLightCycle, 3>> The traffic light's cycles
108+
inline void setCycles(
109+
std::unordered_map<Id, std::array<TrafficLightCycle, 3>> cycles) {
109110
m_cycles = std::move(cycles);
110111
}
111112
/// @brief Set the complementary cycle for a street
@@ -128,8 +129,8 @@ namespace dsm {
128129
/// @param delta Delay, the time to increase or decrease the green times
129130
void decreaseGreenTimes(Delay const delta);
130131
/// @brief Get the traffic light's cycles
131-
/// @return std::unordered_map<Id, std::vector<TrafficLightCycle>> const& The traffic light's cycles
132-
inline std::unordered_map<Id, std::vector<TrafficLightCycle>> const& cycles() const {
132+
/// @return std::unordered_map<Id, std::array<TrafficLightCycle, 3>>& The traffic light's cycles
133+
inline std::unordered_map<Id, std::array<TrafficLightCycle, 3>> const& cycles() const {
133134
return m_cycles;
134135
}
135136
/// @brief Returns true if all the cycles are set to their default values

src/dsm/sources/RoadNetwork.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace dsm {
7979
}
8080
if (node->isTrafficLight()) {
8181
auto& trafficLight = dynamic_cast<TrafficLight&>(*node);
82-
std::unordered_map<Id, std::vector<TrafficLightCycle>> newCycles;
82+
std::unordered_map<Id, std::array<TrafficLightCycle, 3>> newCycles;
8383
for (auto const& [streetId, cycles] : trafficLight.cycles()) {
8484
newCycles.emplace(newStreetIds.at(streetId), std::move(cycles));
8585
}

src/dsm/sources/TrafficLight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace dsm {
3131
}
3232
if (!m_cycles.contains(streetId)) {
3333
TrafficLightCycle defaultCycle(m_cycleTime, 0);
34-
std::vector<TrafficLightCycle> cycles{defaultCycle, defaultCycle, defaultCycle};
34+
std::array<TrafficLightCycle, 3> cycles{defaultCycle, defaultCycle, defaultCycle};
3535
m_cycles.emplace(streetId, cycles);
3636
}
3737
switch (direction) {

0 commit comments

Comments
 (0)