diff --git a/alib2std/src/extensions/container/linear_set.hpp b/alib2std/src/extensions/container/linear_set.hpp index 1917694b5e55997f5b810a97c1a6279fb16b963a..d5df7235f62c78c0d1bea5924b51b072d1bd761c 100644 --- a/alib2std/src/extensions/container/linear_set.hpp +++ b/alib2std/src/extensions/container/linear_set.hpp @@ -75,7 +75,7 @@ class linear_set { */ void sort_unique ( ) { std::sort ( m_data.begin ( ), m_data.end ( ), m_comp ); - m_data.resize ( std::distance ( m_data.begin ( ), std::unique ( m_data.begin ( ), m_data.end ( ), std::bind ( &linear_set < T >::eq, this, std::placeholders::_1, std::placeholders::_2 ) ) ) ); + m_data.erase ( std::unique ( m_data.begin ( ), m_data.end ( ), std::bind ( &linear_set < T >::eq, this, std::placeholders::_1, std::placeholders::_2 ) ), m_data.end ( ) ); } public: diff --git a/alib2std/src/extensions/container/tree.hpp b/alib2std/src/extensions/container/tree.hpp index 661c6ca1726fd4d9e203abf610e969b3c4dd1a97..a2533a96f0bf108143572e6ad62ad81fbe792687 100644 --- a/alib2std/src/extensions/container/tree.hpp +++ b/alib2std/src/extensions/container/tree.hpp @@ -645,11 +645,8 @@ public: * \return updated position iterator pointing to the first node inserted */ const_children_iterator insert ( const_children_iterator position, tree < T > && value ) { - ext::vector < tree > & children = const_cast < ext::vector < tree > & > ( getChildren ( ) ); - - typename ext::vector < tree >::iterator iter = children.insert ( position, std::move ( value ) ); - iter->m_parent = this; - return iter; + value.m_parent = this; + return m_children.insert ( position, std::move ( value ) ); } /** @@ -676,9 +673,7 @@ public: * \return updated position iterator pointing to the first node inserted */ const_children_iterator insert ( const_children_iterator position, const_children_iterator begin, const_children_iterator end ) { - ext::vector < tree > & children = const_cast < ext::vector < tree > & > ( getChildren ( ) ); - - typename ext::vector < tree >::iterator iter = children.insert ( position, begin, end ); + typename ext::vector < tree >::iterator iter = m_children.insert ( position, begin, end ); for ( typename ext::vector < tree >::iterator iterCopy = iter; begin != end; ++begin, ++iterCopy ) iterCopy->m_parent = this; @@ -968,10 +963,8 @@ public: * \param value a subtree to pushback to child list */ void push_back ( ext::tree < T > && value ) { - ext::vector < tree > & children = const_cast < ext::vector < tree > & > ( getChildren ( ) ); - - children.push_back ( std::move ( value ) ); - children.back ( ).m_parent = this; + m_children.push_back ( std::move ( value ) ); + m_children.back ( ).m_parent = this; } /** @@ -1013,9 +1006,7 @@ public: * \param position the specification of position in children where to erase the subtree */ children_iterator erase ( const_children_iterator position ) { - ext::vector < tree > & children = const_cast < ext::vector < tree > & > ( getChildren ( ) ); - - return children.erase ( position ); + return m_children.erase ( position ); } // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------