39 #ifdef CHECK_MEMORY_LEAKS
41 #endif // CHECK_MEMORY_LEAKS
51 MSVehicleContainer::VehicleDepartureVectorSortCrit::operator()
53 return e1.first < e2.first;
66 MSVehicleContainer::DepartFinder::operator()
68 return myTime +
DELTA_T > e.first && myTime <= e.first;
89 VehicleHeap::iterator i =
94 newElem.second.push_back(veh);
98 (*i).second.push_back(veh);
107 VehicleHeap::iterator i =
111 (*i).second.erase(std::remove((*i).second.begin(), (*i).second.end(), veh), (*i).second.end());
118 VehicleHeap::iterator j =
127 stored.reserve(stored.size() + cont.size());
128 copy(cont.begin(), cont.end(), back_inserter(stored));
138 for (
int i = (
int)
array.size(); i-- > 0;) {
139 assert(i < (
int)array2.size());
140 array2[i] =
array[i];
147 for (; hole > 1 && (x.first <
array[ hole / 2 ].first); hole /= 2) {
148 assert((
int)
array.size() > hole);
149 array[hole] = array[ hole / 2 ];
151 assert((
int)
array.size() > hole);
167 assert(
array.size() > 1);
168 return array[ 1 ].second;
177 assert(
array.size() > 1);
178 return array[ 1 ].first;
190 assert(
array.size() > 1);
211 assert((
int)
array.size() > hole);
219 if ((
array[ child ].first < tmp.first)) {
220 assert((
int)
array.size() > hole);
221 array[hole] = array[child];
226 assert((
int)
array.size() > hole);
240 if (i !=
array.begin() + 1) {
243 std::cout << (*i).first;
245 std::cout << std::endl <<
"-------------------------" << std::endl;
250 strm <<
"------------------------------------" << std::endl;
253 for (MSVehicleContainer::VehicleVector::const_iterator i = v.begin(); i != v.end(); ++i) {
254 strm << (*i)->getParameter().depart << std::endl;
VehicleHeap array
The vehicle vector heap.
void remove(SUMOVehicle *veh)
Removes a single vehicle.
SUMOTime topTime() const
Returns the time the uppermost vehicle vector is assigned to.
void percolateDown(int hole)
Moves the elements down.
DepartFinder(SUMOTime time)
constructor
bool isEmpty() const
Returns the information whether the container is empty.
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.
const VehicleVector & top()
Returns the uppermost vehicle vector.
MSVehicleContainer(int capacity=10)
Constructor.
int size() const
Returns the size of the container.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
std::ostream & operator<<(std::ostream &strm, MSVehicleContainer &cont)
std::pair< SUMOTime, VehicleVector > VehicleDepartureVector
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
void showArray() const
Prints the container (the departure times)
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.