Section *Section::getChild(const string &name){ SectionContainer::iterator it = children.find(name); if (it == children.end()) { return NULL; } return it->second; }
void SectionContainer<TValue, TContainer>:: append(const SectionContainer& c) { for(int i = 0; i < c.num_sections(); ++i){ for(const_iterator iter = c.section_begin(i); iter != c.section_end(i);){ const TValue& val = *iter; ++iter; insert(val, i); } } }
void SectionContainer<TValue, TContainer>:: transfer_elements(SectionContainer& c) { for(int i = 0; i < c.num_sections(); ++i){ for(iterator iter = c.section_begin(i); iter != c.section_end(i);){ const TValue& val = *iter; iterator iterOld = iter; ++iter; c.erase(iterOld, i); insert(val, i); } } }
RoadSection::SectionContainer RoadSection::getAdjacent(const Ptr& from) const { // create copy SectionContainer ret = m_sections; // remove every element == from ret.erase(std::remove(ret.begin(), ret.end(), from), ret.end()); // remove every nullptr ret.erase(std::remove(ret.begin(), ret.end(), nullptr), ret.end()); return ret; }
void Section::print(ostream *outStream, int tabLevel){ float percent = ( parent == NULL || parent->microsElapsed == 0 ) ? 100.0f : 100.0f * microsElapsed / parent->microsElapsed; string pname= parent==NULL? "": parent->getName(); for(int i=0; i<tabLevel; ++i) *outStream << "\t"; *outStream << name << ": "; if ( microsElapsed ) { *outStream << int(microsElapsed) << " us"; unsigned int milliseconds = microsElapsed / 1000; unsigned int seconds = milliseconds / 1000; unsigned int minutes = seconds / 60; if ( minutes ) { *outStream << " (" << minutes << "min " << seconds % 60 << "sec)"; } else if ( seconds ) { *outStream << " (" << seconds << "sec " << milliseconds % 1000 << "ms)"; } else if ( milliseconds ) { *outStream << " (" << milliseconds << "ms)"; } outStream->precision(1); *outStream << std::fixed << ", " << percent << "%"; } if ( calls ) { *outStream << ", " << calls << " calls"; } *outStream << "\n"; SectionContainer::iterator it; for(it= children.begin(); it!=children.end(); ++it){ it->second->print(outStream, tabLevel+1); } }