47 MSVehicleContainer::VehicleDepartureVectorSortCrit::operator()
49 return e1.first < e2.first;
62 MSVehicleContainer::DepartFinder::operator()
85 VehicleHeap::iterator i =
90 newElem.second.push_back(veh);
94 (*i).second.push_back(veh);
103 VehicleHeap::iterator i =
107 (*i).second.erase(std::remove((*i).second.begin(), (*i).second.end(), veh), (*i).second.end());
114 VehicleHeap::iterator j =
123 stored.reserve(stored.size() + cont.size());
124 copy(cont.begin(), cont.end(), back_inserter(stored));
134 for (
int i = (
int)
array.size(); i-- > 0;) {
135 assert(i < (
int)array2.size());
136 array2[i] =
array[i];
143 for (; hole > 1 && (x.first <
array[ hole / 2 ].first); hole /= 2) {
144 assert((
int)
array.size() > hole);
145 array[hole] = array[ hole / 2 ];
147 assert((
int)
array.size() > hole);
163 assert(
array.size() > 1);
164 return array[ 1 ].second;
173 assert(
array.size() > 1);
174 return array[ 1 ].first;
186 assert(
array.size() > 1);
207 assert((
int)
array.size() > hole);
215 if ((
array[ child ].first < tmp.first)) {
216 assert((
int)
array.size() > hole);
217 array[hole] = array[child];
222 assert((
int)
array.size() > hole);
236 if (i !=
array.begin() + 1) {
239 std::cout << (*i).first;
241 std::cout << std::endl <<
"-------------------------" << std::endl;
246 strm <<
"------------------------------------" << std::endl;
249 for (MSVehicleContainer::VehicleVector::const_iterator i = v.begin(); i != v.end(); ++i) {
250 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.