mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-05 04:03:46 +00:00
[core] Switch to ankerl::unordered_dense
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
@@ -200,8 +200,9 @@ struct StopOnShape
|
||||
size_t m_index = 0;
|
||||
};
|
||||
|
||||
std::optional<size_t> GetStopIndex(std::unordered_map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
transit::TransitId id, size_t fromIndex, transit::Direction direction)
|
||||
std::optional<size_t> GetStopIndex(
|
||||
ankerl::unordered_dense::map<transit::TransitId, std::vector<size_t>> const & stopIndexes, transit::TransitId id,
|
||||
size_t fromIndex, transit::Direction direction)
|
||||
{
|
||||
auto it = stopIndexes.find(id);
|
||||
CHECK(it != stopIndexes.end(), (id));
|
||||
@@ -218,7 +219,7 @@ std::optional<size_t> GetStopIndex(std::unordered_map<transit::TransitId, std::v
|
||||
}
|
||||
|
||||
std::optional<std::pair<StopOnShape, StopOnShape>> GetStopPairOnShape(
|
||||
std::unordered_map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
ankerl::unordered_dense::map<transit::TransitId, std::vector<size_t>> const & stopIndexes,
|
||||
transit::StopsOnLines const & stopsOnLines, size_t index, size_t fromIndex, transit::Direction direction)
|
||||
{
|
||||
auto const & stopIds = stopsOnLines.m_stopSeq;
|
||||
@@ -264,7 +265,7 @@ Link::Link(transit::TransitId lineId, transit::TransitId shapeId, size_t shapeSi
|
||||
namespace transit
|
||||
{
|
||||
// Static fields.
|
||||
std::unordered_set<std::string> WorldFeed::m_agencyHashes;
|
||||
ankerl::unordered_dense::set<std::string> WorldFeed::m_agencyHashes;
|
||||
|
||||
EdgeTransferId::EdgeTransferId(TransitId fromStopId, TransitId toStopId)
|
||||
: m_fromStopId(fromStopId)
|
||||
@@ -566,7 +567,7 @@ bool WorldFeed::FillStopsEdges()
|
||||
std::sort(allStopTimes.begin(), allStopTimes.end(),
|
||||
[](gtfs::StopTime const & t1, gtfs::StopTime const & t2) { return t1.trip_id < t2.trip_id; });
|
||||
|
||||
std::vector<std::unordered_map<TransitId, LineData>::iterator> linesForRemoval;
|
||||
std::vector<ankerl::unordered_dense::map<TransitId, LineData>::iterator> linesForRemoval;
|
||||
|
||||
for (auto it = m_lines.m_data.begin(); it != m_lines.m_data.end(); ++it)
|
||||
{
|
||||
@@ -644,7 +645,7 @@ bool WorldFeed::FillStopsEdges()
|
||||
|
||||
bool WorldFeed::FillLinesAndShapes()
|
||||
{
|
||||
std::unordered_map<gtfs::Id, gtfs::Shape> shapes;
|
||||
ankerl::unordered_dense::map<gtfs::Id, gtfs::Shape> shapes;
|
||||
for (auto const & shape : m_feed.get_shapes())
|
||||
shapes[shape.shape_id].emplace_back(shape);
|
||||
|
||||
@@ -653,7 +654,7 @@ bool WorldFeed::FillLinesAndShapes()
|
||||
|
||||
auto const getShape = [&shapes](gtfs::Id const & gtfsShapeId) -> gtfs::Shape const & { return shapes[gtfsShapeId]; };
|
||||
|
||||
std::unordered_map<gtfs::Id, gtfs::StopTimes> stopTimes;
|
||||
ankerl::unordered_dense::map<gtfs::Id, gtfs::StopTimes> stopTimes;
|
||||
for (auto const & stop_time : m_feed.get_stop_times())
|
||||
stopTimes[stop_time.trip_id].emplace_back(stop_time);
|
||||
|
||||
@@ -743,7 +744,7 @@ void WorldFeed::ModifyLinesAndShapes()
|
||||
IdSet shapesForRemoval;
|
||||
|
||||
// Shape id matching to the line id linked to this shape id.
|
||||
std::unordered_map<TransitId, TransitId> matchingCache;
|
||||
ankerl::unordered_dense::map<TransitId, TransitId> matchingCache;
|
||||
|
||||
for (size_t i = 1; i < links.size(); ++i)
|
||||
{
|
||||
@@ -863,7 +864,7 @@ void WorldFeed::FillLinesSchedule()
|
||||
|
||||
std::optional<Direction> WorldFeed::ProjectStopsToShape(
|
||||
ShapesIter & itShape, StopsOnLines const & stopsOnLines,
|
||||
std::unordered_map<TransitId, std::vector<size_t>> & stopsToIndexes)
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<size_t>> & stopsToIndexes)
|
||||
{
|
||||
IdList const & stopIds = stopsOnLines.m_stopSeq;
|
||||
TransitId const shapeId = itShape->first;
|
||||
@@ -934,10 +935,10 @@ std::optional<Direction> WorldFeed::ProjectStopsToShape(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unordered_map<TransitId, std::vector<StopsOnLines>> WorldFeed::GetStopsForShapeMatching()
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<StopsOnLines>> WorldFeed::GetStopsForShapeMatching()
|
||||
{
|
||||
// Shape id and list of stop sequences matched to the corresponding lines.
|
||||
std::unordered_map<TransitId, std::vector<StopsOnLines>> stopsOnShapes;
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<StopsOnLines>> stopsOnShapes;
|
||||
|
||||
// We build lists of stops relevant to corresponding shapes. There could be multiple different
|
||||
// stops lists linked to the same shape.
|
||||
@@ -982,7 +983,7 @@ std::pair<size_t, size_t> WorldFeed::ModifyShapes()
|
||||
auto itShape = m_shapes.m_data.find(shapeId);
|
||||
CHECK(itShape != m_shapes.m_data.end(), (shapeId));
|
||||
|
||||
std::unordered_map<TransitId, std::vector<size_t>> stopToShapeIndex;
|
||||
ankerl::unordered_dense::map<TransitId, std::vector<size_t>> stopToShapeIndex;
|
||||
|
||||
for (auto & stopsOnLines : stopsLists)
|
||||
{
|
||||
@@ -1124,7 +1125,7 @@ void WorldFeed::FillTransfers()
|
||||
|
||||
void WorldFeed::FillGates()
|
||||
{
|
||||
std::unordered_map<std::string, std::vector<GateData>> parentToGates;
|
||||
ankerl::unordered_dense::map<std::string, std::vector<GateData>> parentToGates;
|
||||
for (auto const & stop : m_feed.get_stops())
|
||||
{
|
||||
if (stop.location_type == gtfs::StopLocationType::EntranceExit && !stop.parent_station.empty())
|
||||
@@ -1193,11 +1194,11 @@ bool WorldFeed::SpeedExceedsMaxVal(EdgeId const & edgeId, EdgeData const & edgeD
|
||||
return speedExceedsMaxVal;
|
||||
}
|
||||
|
||||
bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corruptedLineIds)
|
||||
bool WorldFeed::ClearFeedByLineIds(ankerl::unordered_dense::set<TransitId> const & corruptedLineIds)
|
||||
{
|
||||
std::unordered_set<TransitId> corruptedRouteIds;
|
||||
std::unordered_set<TransitId> corruptedShapeIds;
|
||||
std::unordered_set<TransitId> corruptedNetworkIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedRouteIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedShapeIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedNetworkIds;
|
||||
|
||||
for (auto lineId : corruptedLineIds)
|
||||
{
|
||||
@@ -1226,7 +1227,7 @@ bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corrupt
|
||||
DeleteAllEntriesByIds(m_networks.m_data, corruptedNetworkIds);
|
||||
DeleteAllEntriesByIds(m_lines.m_data, corruptedLineIds);
|
||||
|
||||
std::unordered_set<TransitId> corruptedStopIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedStopIds;
|
||||
|
||||
// We fill |corruptedStopIds| and delete corresponding edges from |m_edges|.
|
||||
for (auto it = m_edges.m_data.begin(); it != m_edges.m_data.end();)
|
||||
@@ -1298,7 +1299,7 @@ bool WorldFeed::ClearFeedByLineIds(std::unordered_set<TransitId> const & corrupt
|
||||
|
||||
bool WorldFeed::UpdateEdgeWeights()
|
||||
{
|
||||
std::unordered_set<TransitId> corruptedLineIds;
|
||||
ankerl::unordered_dense::set<TransitId> corruptedLineIds;
|
||||
|
||||
for (auto & [edgeId, edgeData] : m_edges.m_data)
|
||||
{
|
||||
@@ -1449,7 +1450,8 @@ void Routes::Write(IdSet const & ids, std::ofstream & stream) const
|
||||
}
|
||||
}
|
||||
|
||||
void Lines::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & ids, std::ofstream & stream) const
|
||||
void Lines::Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & ids,
|
||||
std::ofstream & stream) const
|
||||
{
|
||||
for (auto const & [lineId, data] : ids)
|
||||
{
|
||||
@@ -1468,7 +1470,7 @@ void Lines::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & ids
|
||||
}
|
||||
}
|
||||
|
||||
void LinesMetadata::Write(std::unordered_map<TransitId, LineSegmentInRegion> const & linesInRegion,
|
||||
void LinesMetadata::Write(ankerl::unordered_dense::map<TransitId, LineSegmentInRegion> const & linesInRegion,
|
||||
std::ofstream & stream) const
|
||||
{
|
||||
for (auto const & [lineId, lineData] : linesInRegion)
|
||||
|
||||
Reference in New Issue
Block a user