SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A structure storing information about which edges were joined 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 #include <cassert> 00032 #include <iostream> 00033 #include "NBJoinedEdgesMap.h" 00034 #include "NBEdgeCont.h" 00035 #include "NBEdge.h" 00036 #include <algorithm> 00037 #include <iterator> 00038 00039 #ifdef CHECK_MEMORY_LEAKS 00040 #include <foreign/nvwa/debug_new.h> 00041 #endif // CHECK_MEMORY_LEAKS 00042 00043 00044 // =========================================================================== 00045 // member method definitions 00046 // =========================================================================== 00047 NBJoinedEdgesMap::NBJoinedEdgesMap() {} 00048 00049 00050 NBJoinedEdgesMap::~NBJoinedEdgesMap() {} 00051 00052 00053 void 00054 NBJoinedEdgesMap::init(NBEdgeCont& ec) { 00055 const std::vector<std::string> edgeNames = ec.getAllNames(); 00056 myMap.clear(); 00057 for (std::vector<std::string>::const_iterator i = edgeNames.begin(); i != edgeNames.end(); i++) { 00058 MappedEdgesVector e; 00059 e.push_back(*i); 00060 myMap[*i] = e; 00061 myLengths[*i] = ec.retrieve(*i)->getLength(); 00062 } 00063 } 00064 00065 00066 void 00067 NBJoinedEdgesMap::appended(const std::string& to, const std::string& what) { 00068 copy(myMap[what].begin(), myMap[what].end(), back_inserter(myMap[to])); 00069 JoinedEdgesMap::iterator i = myMap.find(what); 00070 assert(i != myMap.end()); 00071 myMap.erase(i); 00072 } 00073 00074 00075 std::ostream& 00076 operator<<(std::ostream& os, const NBJoinedEdgesMap& jemap) { 00077 NBJoinedEdgesMap::JoinedEdgesMap::const_iterator i; 00078 for (i = jemap.myMap.begin(); i != jemap.myMap.end(); ++i) { 00079 os << (*i).first << "\t"; 00080 const NBJoinedEdgesMap::MappedEdgesVector& e = (*i).second; 00081 for (NBJoinedEdgesMap::MappedEdgesVector::const_iterator j = e.begin(); j != e.end(); ++j) { 00082 os << (*j) << ":" << jemap.myLengths.find(*j)->second << "\t"; 00083 } 00084 os << std::endl; 00085 } 00086 return os; 00087 } 00088 00089 00090 00091 /****************************************************************************/ 00092