diff --git a/src/ShortestPath/ShortestPath.h b/src/ShortestPath/ShortestPath.h index c498ece27c1019e56d17ccf0a8e7bb4acef166db..8ad32901153e96d46f5414919f1c3313bdcf3462 100644 --- a/src/ShortestPath/ShortestPath.h +++ b/src/ShortestPath/ShortestPath.h @@ -9,26 +9,19 @@ template <typename KeyPoint> class ShortestPath { - int _duration; +protected: std::vector<KeyPoint> _keyPoints; - explicit ShortestPath(int duration) { _duration = duration;} public: - [[nodiscard]] int getDuration() const { - return _duration; - } - - void setDuration(int duration) { - _duration = duration; - } + explicit ShortestPath() = default; [[nodiscard]] const std::vector<KeyPoint> &getKeyPoints() const { return _keyPoints; } void replaceKeyPoint(int keyPointIndex, KeyPoint& value) { - _keyPoints.assign(keyPointIndex, value); + _keyPoints.at(keyPointIndex) = value; } /** diff --git a/src/ShortestPath/Transit/TransitShortestPath.h b/src/ShortestPath/Transit/TransitShortestPath.h index 64be4fd1c6d0a0e9798449da2d975365c45ff574..9aee17ce81a54dbedeeb026764ffef5e5b076eb4 100644 --- a/src/ShortestPath/Transit/TransitShortestPath.h +++ b/src/ShortestPath/Transit/TransitShortestPath.h @@ -10,8 +10,15 @@ #include "TransitAlgorithmState.h" class TransitShortestPath : public ShortestPath<LineStop> { +private: + int _arrivalTime; public: + explicit TransitShortestPath(const TransitAlgorithmState& state) { + _arrivalTime = state.getInstant(); + std::move(state.getConnections().begin(), state.getConnections().end(),_keyPoints.begin()); + } + /** * Strict dominance between two transit shortest path * @param rhs @@ -19,19 +26,21 @@ public: */ [[nodiscard]] bool strictlyDominates(const TransitShortestPath& rhs) const { return this->getKeyPoints().size() <= rhs.getKeyPoints().size() - && this->getDuration() <= rhs.getDuration(); + && this->getArrivalTime() <= rhs.getArrivalTime(); } bool operator<(const TransitShortestPath& rhs) const { - return this->getDuration() < rhs.getDuration() || - (this->getDuration() == rhs.getDuration() && this->getKeyPoints().size() < rhs.getKeyPoints().size()); + return this->getArrivalTime() < rhs.getArrivalTime() || + (this->getArrivalTime() == rhs.getArrivalTime() && this->getKeyPoints().size() < rhs.getKeyPoints().size()); } bool operator>(const TransitShortestPath& rhs) const { - return this->getDuration() > rhs.getDuration() || - (this->getDuration() == rhs.getDuration() && this->getKeyPoints().size() > rhs.getKeyPoints().size()); + return this->getArrivalTime() > rhs.getArrivalTime() || + (this->getArrivalTime() == rhs.getArrivalTime() && this->getKeyPoints().size() > rhs.getKeyPoints().size()); } + [[nodiscard]] int getArrivalTime() const { return _arrivalTime; } + // FIXME: check if I can properly remove this or if shortest path comparisons may be useful // [[nodiscard]] bool strictlyDominates(const TransitAlgorithmState& rhs) const {