StripedSet: replace ensure() with update()
[libcds.git] / cds / container / striped_set / std_vector.h
index 278bc566bcfb37fe3a0c81a5702829ea4ec4a87c..039618bb1c275724d2d9a699e4cf972fe4cfb416 100644 (file)
@@ -154,11 +154,14 @@ namespace cds { namespace intrusive { namespace striped_set {
             }
 
             template <typename Q, typename Func>
-            std::pair<bool, bool> ensure( const Q& val, Func func )
+            std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
             {
                 iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
                 if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
                     // insert new
+                    if ( !bAllowInsert )
+                        return std::make_pair( false, false );
+
                     value_type newItem( val );
                     it = m_Vector.insert( it, newItem );
                     func( true, *it, val );