SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSVehicleContainer.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // vehicles sorted by their departures
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSVehicleContainer_h
23 #define MSVehicleContainer_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <iostream>
37 #include "MSNet.h"
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSVehicle;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
56 public:
58  typedef std::vector<SUMOVehicle*> VehicleVector;
59 
62  typedef std::pair<SUMOTime, VehicleVector> VehicleDepartureVector;
63 
64 public:
66  MSVehicleContainer(size_t capacity = 10);
67 
70 
72  void add(SUMOVehicle* veh);
73 
75  void add(SUMOTime time, const VehicleVector& cont);
76 
78  bool anyWaitingFor(SUMOTime time) const;
79 
81  const VehicleVector& top();
82 
84  SUMOTime topTime() const;
85 
87  void pop();
88 
90  bool isEmpty() const;
91 
93  size_t size() const;
94 
96  void showArray() const;
97 
99  friend std::ostream& operator << (std::ostream& strm,
100  MSVehicleContainer& cont);
101 
102 private:
105  void addReplacing(const VehicleDepartureVector& cont);
106 
108  bool isFull() const;
109 
112  public:
114  bool operator()(const VehicleDepartureVector& e1,
115  const VehicleDepartureVector& e2) const;
116  };
117 
119  class DepartFinder {
120  public:
122  explicit DepartFinder(SUMOTime time);
123 
125  bool operator()(const VehicleDepartureVector& e) const;
126 
127  private:
130  };
131 
134 
136  typedef std::vector<VehicleDepartureVector> VehicleHeap;
137 
140 
142  void percolateDown(int hole);
143 
144 };
145 
146 
147 #endif
148 
149 /****************************************************************************/
150