diff --git a/src/netedit/elements/GNEAttributeCarrier.cpp b/src/netedit/elements/GNEAttributeCarrier.cpp index 8fc2afea9a3..06843c87f57 100644 --- a/src/netedit/elements/GNEAttributeCarrier.cpp +++ b/src/netedit/elements/GNEAttributeCarrier.cpp @@ -385,8 +385,9 @@ GNEAttributeCarrier::parse(const std::string& value) { template<> std::vector GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { // Declare string vector - std::vector edgeIds = GNEAttributeCarrier::parse > (value); + const auto edgeIds = GNEAttributeCarrier::parse > (value); std::vector parsedEdges; + parsedEdges.reserve(edgeIds.size()); // Iterate over edges IDs, retrieve Edges and add it into parsedEdges for (const auto& edgeID : edgeIds) { GNEEdge* retrievedEdge = net->getAttributeCarriers()->retrieveEdge(edgeID, false); @@ -401,11 +402,18 @@ GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { } +template<> GNEHierarchicalContainerChildren +GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { + return GNEHierarchicalContainerChildren(parse >(net, value)); +} + + template<> std::vector GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { // Declare string vector - std::vector laneIds = GNEAttributeCarrier::parse > (value); + const auto laneIds = GNEAttributeCarrier::parse > (value); std::vector parsedLanes; + parsedLanes.reserve(laneIds.size()); // Iterate over lanes IDs, retrieve Lanes and add it into parsedLanes for (const auto& laneID : laneIds) { GNELane* retrievedLane = net->getAttributeCarriers()->retrieveLane(laneID, false); @@ -420,6 +428,12 @@ GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { } +template<> GNEHierarchicalContainerChildren +GNEAttributeCarrier::parse(GNENet* net, const std::string& value) { + return GNEHierarchicalContainerChildren(parse >(net, value)); +} + + template<> std::string GNEAttributeCarrier::parseIDs(const std::vector& ACs) { // obtain ID's of edges and return their join diff --git a/src/netedit/elements/GNEHierarchicalContainerChildrenHash.h b/src/netedit/elements/GNEHierarchicalContainerChildrenHash.h index 484cfcc74c8..7863d09a2e6 100644 --- a/src/netedit/elements/GNEHierarchicalContainerChildrenHash.h +++ b/src/netedit/elements/GNEHierarchicalContainerChildrenHash.h @@ -20,14 +20,14 @@ #pragma once #include -#include +#include // =========================================================================== // class definitions // =========================================================================== template -class GNEHierarchicalContainerChildrenHash : public std::unordered_set { +class GNEHierarchicalContainerChildrenHash : public std::set { public: /// @brief default constructor @@ -35,7 +35,7 @@ class GNEHierarchicalContainerChildrenHash : public std::unordered_set { } /// @brief parameter constructor - GNEHierarchicalContainerChildrenHash(const std::unordered_set& elements) : - std::unordered_set(elements) { + GNEHierarchicalContainerChildrenHash(const std::set& elements) : + std::set(elements) { } }; diff --git a/src/netedit/elements/GNEHierarchicalElement.h b/src/netedit/elements/GNEHierarchicalElement.h index 83cd789b006..2f5e6660ca1 100644 --- a/src/netedit/elements/GNEHierarchicalElement.h +++ b/src/netedit/elements/GNEHierarchicalElement.h @@ -196,7 +196,7 @@ class GNEHierarchicalElement : public GNEAttributeCarrier { /// @brief replace children in the given edited element template - void replaceChildElements(T* editedElement, const std::vector& newChildren) { + void replaceChildElements(T* editedElement, const GNEHierarchicalContainerChildren& newChildren) { // remove edited elements from children for (const auto& child : myHierarchicalStructure.getChildren()) { child->removeChildElement(editedElement); diff --git a/src/netedit/elements/GNEHierarchicalStructure.cpp b/src/netedit/elements/GNEHierarchicalStructure.cpp index 8b931305243..761d1eb1efd 100644 --- a/src/netedit/elements/GNEHierarchicalStructure.cpp +++ b/src/netedit/elements/GNEHierarchicalStructure.cpp @@ -437,43 +437,43 @@ GNEHierarchicalStructure::getChildren() const { template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildJunctions = newChildren; } template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildEdges = newChildren; } template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildLanes = newChildren; } template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildAdditionals = newChildren; } template<> void -GNEHierarchicalStructure::setChildrenHash(const std::unordered_set& newChildren) { +GNEHierarchicalStructure::setChildrenHash(const GNEHierarchicalContainerChildrenHash& newChildren) { myChildSourceSinks = newChildren; } template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildDemandElements = newChildren; } template<> void -GNEHierarchicalStructure::setChildren(const std::vector& newChildren) { +GNEHierarchicalStructure::setChildren(const GNEHierarchicalContainerChildren& newChildren) { myChildGenericDatas = newChildren; } diff --git a/src/netedit/elements/GNEHierarchicalStructure.h b/src/netedit/elements/GNEHierarchicalStructure.h index 388e2f90656..40ee3bee00c 100644 --- a/src/netedit/elements/GNEHierarchicalStructure.h +++ b/src/netedit/elements/GNEHierarchicalStructure.h @@ -97,11 +97,11 @@ class GNEHierarchicalStructure { /// @brief set children template - void setChildren(const std::vector& newChildren); + void setChildren(const GNEHierarchicalContainerChildren& newChildren); /// @brief set children hash template - void setChildrenHash(const std::unordered_set& newChildren); + void setChildrenHash(const GNEHierarchicalContainerChildrenHash& newChildren); private: /// @brief parents junctions diff --git a/src/netedit/elements/additional/GNEAdditional.cpp b/src/netedit/elements/additional/GNEAdditional.cpp index 8f1a335156d..fa85ca57df0 100644 --- a/src/netedit/elements/additional/GNEAdditional.cpp +++ b/src/netedit/elements/additional/GNEAdditional.cpp @@ -664,13 +664,13 @@ GNEAdditional::replaceAdditionalParentLanes(const std::string& value) { void GNEAdditional::replaceAdditionalChildEdges(const std::string& value) { - replaceChildElements(this, parse >(getNet(), value)); + replaceChildElements(this, parse >(getNet(), value)); } void GNEAdditional::replaceAdditionalChildLanes(const std::string& value) { - replaceChildElements(this, parse >(getNet(), value)); + replaceChildElements(this, parse >(getNet(), value)); }