// ------------------------------------------------------------------------------------------------ std::vector<const Connection*> Document::GetConnectionsSequenced(uint64_t id, bool is_src, const ConnectionMap& conns, const char* const* classnames, size_t count) const { ai_assert(classnames); ai_assert(count != 0 && count <= MAX_CLASSNAMES); size_t lenghts[MAX_CLASSNAMES]; const size_t c = count; for (size_t i = 0; i < c; ++i) { lenghts[i] = strlen(classnames[i]); } std::vector<const Connection*> temp; const std::pair<ConnectionMap::const_iterator,ConnectionMap::const_iterator> range = conns.equal_range(id); temp.reserve(std::distance(range.first,range.second)); for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) { const Token& key = (is_src ? (*it).second->LazyDestinationObject() : (*it).second->LazySourceObject() ).GetElement().KeyToken(); const char* obtype = key.begin(); for (size_t i = 0; i < c; ++i) { ai_assert(classnames[i]); if(static_cast<size_t>(std::distance(key.begin(),key.end())) == lenghts[i] && !strncmp(classnames[i],obtype,lenghts[i])) { obtype = NULL; break; } } if(obtype) { continue; } temp.push_back((*it).second); } std::sort(temp.begin(), temp.end(), std::mem_fun(&Connection::Compare)); return temp; // NRVO should handle this }
// ------------------------------------------------------------------------------------------------ std::vector<const Connection*> Document::GetConnectionsSequenced(uint64_t id, const ConnectionMap& conns) const { std::vector<const Connection*> temp; const std::pair<ConnectionMap::const_iterator,ConnectionMap::const_iterator> range = conns.equal_range(id); temp.reserve(std::distance(range.first,range.second)); for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) { temp.push_back((*it).second); } std::sort(temp.begin(), temp.end(), std::mem_fun(&Connection::Compare)); return temp; // NRVO should handle this }