Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/router/ROHelper.h
169667 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file ROHelper.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Sept 2002
18
///
19
// Some helping methods for router
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <functional>
25
#include <vector>
26
#include "ROEdge.h"
27
#include "ROVehicle.h"
28
29
30
// ===========================================================================
31
// class definitions
32
// ===========================================================================
33
/**
34
* @class ROVehicleByDepartureComperator
35
* @brief A function for sorting vehicles by their departure time
36
*
37
* In the case two vehicles have the same departure time, they are sorted
38
* lexically.
39
*/
40
class ROVehicleByDepartureComperator : public std::less<ROVehicle*> {
41
public:
42
/// @brief Constructor
43
explicit ROVehicleByDepartureComperator() { }
44
45
/// @brief Destructor
46
~ROVehicleByDepartureComperator() { }
47
48
/** @brief Comparing operator
49
*
50
* Returns whether the first vehicles wants to leave later than the second.
51
* If both vehicles have the same departure time, a lexical comparison is
52
* done.
53
*
54
* @param[i] veh1 The first vehicle to compare
55
* @param[i] veh2 The second vehicle to compare
56
* @return Whether the first vehicle departs later than the second
57
* @todo Check whether both vehicles can be const
58
*/
59
bool operator()(ROVehicle* veh1, ROVehicle* veh2) const {
60
if (veh1->getDepart() == veh2->getDepart()) {
61
return veh1->getID() > veh2->getID();
62
}
63
return veh1->getDepart() > veh2->getDepart();
64
}
65
};
66
67
68
/**
69
* @namespace ROHelper
70
* @brief Some helping methods for router
71
*/
72
namespace ROHelper {
73
/** @brief Checks whether the given edge list contains loops and removes them
74
*
75
* @param[in] edges The list of edges to remove loops from
76
*/
77
void recheckForLoops(ConstROEdgeVector& edges, const ConstROEdgeVector& mandatory);
78
79
bool noMandatory(const ConstROEdgeVector& mandatory,
80
ConstROEdgeVector::const_iterator start,
81
ConstROEdgeVector::const_iterator end);
82
}
83
84