46 MSVehicleContainer::VehicleDepartureVectorSortCrit::operator()
48 return e1.first < e2.first;
61 MSVehicleContainer::DepartFinder::operator()
84 VehicleHeap::iterator i =
89 newElem.second.push_back(veh);
93 (*i).second.push_back(veh);
102 VehicleHeap::iterator i =
106 (*i).second.erase(std::remove((*i).second.begin(), (*i).second.end(), veh), (*i).second.end());
113 VehicleHeap::iterator j =
122 stored.reserve(stored.size() + cont.size());
123 copy(cont.begin(), cont.end(), back_inserter(stored));
133 for (
int i = (
int)
array.size(); i-- > 0;) {
134 assert(i < (
int)array2.size());
135 array2[i] =
array[i];
142 for (; hole > 1 && (x.first <
array[ hole / 2 ].first); hole /= 2) {
143 assert((
int)
array.size() > hole);
144 array[hole] = array[ hole / 2 ];
146 assert((
int)
array.size() > hole);
162 assert(
array.size() > 1);
163 return array[ 1 ].second;
172 assert(
array.size() > 1);
173 return array[ 1 ].first;
185 assert(
array.size() > 1);
206 assert((
int)
array.size() > hole);
214 if ((
array[ child ].first < tmp.first)) {
215 assert((
int)
array.size() > hole);
216 array[hole] = array[child];
221 assert((
int)
array.size() > hole);
235 if (i !=
array.begin() + 1) {
238 std::cout << (*i).first;
240 std::cout << std::endl <<
"-------------------------" << std::endl;
245 strm <<
"------------------------------------" << std::endl;
248 for (MSVehicleContainer::VehicleVector::const_iterator i = v.begin(); i != v.end(); ++i) {
249 strm << (*i)->getParameter().depart << std::endl;
friend std::ostream & operator<<(std::ostream &strm, MSVehicleContainer &cont)
Prints the contents of the container.
int size() const
Returns the size of the container.
VehicleHeap array
The vehicle vector heap.
void remove(SUMOVehicle *veh)
Removes a single vehicle.
void percolateDown(int hole)
Moves the elements down.
DepartFinder(SUMOTime time)
constructor
bool isEmpty() const
Returns the information whether the container is empty.
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
int currentSize
Number of elements in heap.
void pop()
Removes the uppermost vehicle vector.
Representation of a vehicle.
SUMOTime depart
The vehicle's departure time.
void add(SUMOVehicle *veh)
Adds a single vehicle.
void showArray() const
Prints the container (the departure times)
const VehicleVector & top()
Returns the uppermost vehicle vector.
SUMOTime myTime
the searched departure time
MSVehicleContainer(int capacity=10)
Constructor.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
SUMOTime topTime() const
Returns the time the uppermost vehicle vector is assigned to.
std::pair< SUMOTime, VehicleVector > VehicleDepartureVector
void addReplacing(const VehicleDepartureVector &cont)
Replaces the existing single departure time vector by the one given.
Searches for the VehicleDepartureVector with the wished depart.
~MSVehicleContainer()
Destructor.