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