struct departure_compare {
bool operator() (const Leg* lhs, const Leg* rhs) const
{
return lhs->CurrentDepartureTime() < rhs->CurrentDepartureTime();
}
};
class Station
{
uint station_number_;
std::set<Leg *, departure_compare> departure_legs_in_order_; // legs that depart from this station in order of departure time
public:
Station(uint station_number) : station_number_(station_number) {};
void addDepartureLeg(Leg *leg) { departure_legs_in_order_.insert(leg); };
const std::set<Leg *, departure_compare>& DepartureLegs() const { return departure_legs_in_order_; };
uint StationNumber() { return station_number_; };
};
I call this in a loop
Leg *new_leg = new Leg();
start_station->addDepartureLeg(new_leg); // start_station of type station
Now i recognized that some times, it doesn't insert the new_leg into this structure. Now i looked at the documentation which says that if it is already in the set structure that it doesn't insert new_leg. But how is this possible, if i always create a new Pointer (Shouldn't the address be unique)?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire