Skip to content
Snippets Groups Projects
Commit ffcb2b7c authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fixes in linear set

parent 8f1453db
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -29,7 +29,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<int>::eq, std::ref( * this ), std::placeholders::_1, std::placeholders::_2 ) ) ) );
m_data.resize ( std::distance ( m_data.begin ( ), std::unique ( m_data.begin ( ), m_data.end ( ), std::bind ( &linear_set < T >::eq, std::ref( * this ), std::placeholders::_1, std::placeholders::_2 ) ) ) );
}
 
public:
......@@ -136,8 +136,16 @@ public:
return m_data.erase ( position );
}
 
size_t erase (const T& val) {
const_iterator position = lower_bound ( val );
if ( position != end ( ) && eq ( * position, val ) )
return m_data.erase ( position ), 1;
else
return 0;
}
iterator erase (const_iterator first, const_iterator last) {
return m_data.erace ( first, last );
return m_data.erase ( first, last );
}
 
const_iterator find (const T& val) const {
......
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