From e2426b22fa0e605834d016d7116d0a8ed2e8223e Mon Sep 17 00:00:00 2001 From: fonsinchen Date: Sun, 10 Jul 2016 11:57:16 +0000 Subject: (svn r27612) -Codechange: Replace three uses of std::list with std::queue/vector. (JGR) --- src/linkgraph/demands.cpp | 18 +++++++++--------- src/linkgraph/linkgraph_gui.h | 4 ++-- src/linkgraph/refresh.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/linkgraph/demands.cpp b/src/linkgraph/demands.cpp index 767bec2c9..f4afbabf0 100644 --- a/src/linkgraph/demands.cpp +++ b/src/linkgraph/demands.cpp @@ -2,11 +2,11 @@ #include "../stdafx.h" #include "demands.h" -#include +#include #include "../safeguards.h" -typedef std::list NodeList; +typedef std::queue NodeList; /** * Scale various things according to symmetric/asymmetric distribution. @@ -172,11 +172,11 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler) for (NodeID node = 0; node < job.Size(); node++) { scaler.AddNode(job[node]); if (job[node].Supply() > 0) { - supplies.push_back(node); + supplies.push(node); num_supplies++; } if (job[node].Demand() > 0) { - demands.push_back(node); + demands.push(node); num_demands++; } } @@ -191,17 +191,17 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler) while (!supplies.empty() && !demands.empty()) { NodeID from_id = supplies.front(); - supplies.pop_front(); + supplies.pop(); for (uint i = 0; i < num_demands; ++i) { assert(!demands.empty()); NodeID to_id = demands.front(); - demands.pop_front(); + demands.pop(); if (from_id == to_id) { /* Only one node with supply and demand left */ if (demands.empty() && supplies.empty()) return; - demands.push_back(to_id); + demands.push(to_id); continue; } @@ -236,7 +236,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler) scaler.SetDemands(job, from_id, to_id, demand_forw); if (scaler.HasDemandLeft(job[to_id])) { - demands.push_back(to_id); + demands.push(to_id); } else { num_demands--; } @@ -245,7 +245,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler) } if (job[from_id].UndeliveredSupply() != 0) { - supplies.push_back(from_id); + supplies.push(from_id); } else { num_supplies--; } diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index fcf81817f..1e306a44d 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -17,7 +17,7 @@ #include "../widget_type.h" #include "linkgraph_base.h" #include -#include +#include /** * Properties of a link between two stations. @@ -39,7 +39,7 @@ class LinkGraphOverlay { public: typedef std::map StationLinkMap; typedef std::map LinkMap; - typedef std::list > StationSupplyList; + typedef std::vector > StationSupplyList; static const uint8 LINK_COLOURS[]; diff --git a/src/linkgraph/refresh.h b/src/linkgraph/refresh.h index 496729df7..6687b8a3b 100644 --- a/src/linkgraph/refresh.h +++ b/src/linkgraph/refresh.h @@ -14,7 +14,7 @@ #include "../cargo_type.h" #include "../vehicle_base.h" -#include +#include #include #include @@ -79,7 +79,7 @@ protected: bool operator<(const Hop &other) const; }; - typedef std::list RefitList; + typedef std::vector RefitList; typedef std::map CapacitiesMap; typedef std::set HopSet; -- cgit v1.2.3-70-g09d2