Skip to content
Snippets Groups Projects
Commit c50317c0 authored by Jan Trávníček's avatar Jan Trávníček Committed by Tomáš Pecka
Browse files

improvements

parent 72d841ed
No related branches found
No related tags found
1 merge request!119Merge jt
......@@ -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:
......
......@@ -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 );
}
 
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment