FlowStatMap: Replace RB-tree with btree-indexed vector
This commit is contained in:
@@ -57,7 +57,7 @@ void FlowMapper::Run(LinkGraphJob &job) const
|
||||
* LinkGraph::Monthly(). */
|
||||
uint runtime = (job.StartDateTicks() / DAY_TICKS) - job.LastCompression() + 1;
|
||||
for (FlowStatMap::iterator i = flows.begin(); i != flows.end(); ++i) {
|
||||
i->second.ScaleToMonthly(runtime);
|
||||
i->ScaleToMonthly(runtime);
|
||||
}
|
||||
}
|
||||
/* Clear paths. */
|
||||
|
@@ -146,27 +146,30 @@ void LinkGraphJob::FinaliseJob()
|
||||
* somewhere. Do delete them and also reroute relevant cargo if
|
||||
* automatic distribution has been turned off for that cargo. */
|
||||
for (FlowStatMap::iterator it(ge.flows.begin()); it != ge.flows.end();) {
|
||||
FlowStatMap::iterator new_it = flows.find(it->first);
|
||||
FlowStatMap::iterator new_it = flows.find(it->GetOrigin());
|
||||
if (new_it == flows.end()) {
|
||||
if (_settings_game.linkgraph.GetDistributionType(this->Cargo()) != DT_MANUAL) {
|
||||
it->second.Invalidate();
|
||||
it->Invalidate();
|
||||
++it;
|
||||
} else {
|
||||
FlowStat shares(INVALID_STATION, 1);
|
||||
it->second.SwapShares(shares);
|
||||
ge.flows.erase(it++);
|
||||
FlowStat shares(INVALID_STATION, INVALID_STATION, 1);
|
||||
it->SwapShares(shares);
|
||||
it = ge.flows.erase(it);
|
||||
for (FlowStat::SharesMap::const_iterator shares_it(shares.GetShares()->begin());
|
||||
shares_it != shares.GetShares()->end(); ++shares_it) {
|
||||
RerouteCargo(st, this->Cargo(), shares_it->second, st->index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
it->second.SwapShares(new_it->second);
|
||||
it->SwapShares(*new_it);
|
||||
flows.erase(new_it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
ge.flows.insert(flows.begin(), flows.end());
|
||||
for (FlowStatMap::iterator it(flows.begin()); it != flows.end(); ++it) {
|
||||
ge.flows.insert(std::move(*it));
|
||||
}
|
||||
ge.flows.SortStorage();
|
||||
InvalidateWindowData(WC_STATION_VIEW, st->index, this->Cargo());
|
||||
}
|
||||
}
|
||||
|
@@ -187,8 +187,8 @@ public:
|
||||
const FlowStatMap &flows = this->job[node].Flows();
|
||||
FlowStatMap::const_iterator it = flows.find(this->job[source].Station());
|
||||
if (it != flows.end()) {
|
||||
this->it = it->second.GetShares()->begin();
|
||||
this->end = it->second.GetShares()->end();
|
||||
this->it = it->GetShares()->begin();
|
||||
this->end = it->GetShares()->end();
|
||||
} else {
|
||||
this->it = FlowStat::empty_sharesmap.begin();
|
||||
this->end = FlowStat::empty_sharesmap.end();
|
||||
|
Reference in New Issue
Block a user