std::pair<bool, bool> ret = base_class::update_at( refHead, *pNode,
[&pItemFound](bool, node_type& item, node_type&){ pItemFound = &item; },
bAllowInsert );
- assert( pItemFound != nullptr );
- if ( ret.first && ret.second )
+ if ( ret.second )
pNode.release();
return std::make_pair( pItemFound, ret.second );
}
if ( ret.second )
++m_ItemCounter;
-
+ else if ( ret.first == refBucket.end() )
+ return std::make_pair( end(), false );
return std::make_pair( iterator( ret.first, &refBucket, m_Buckets + bucket_count() ), ret.second );
}
//@cond
template <typename K, typename Func>
std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
{
- std::pair<bool, bool> bRet = bucket( key ).update( key, func );
- if ( bRet.first && bRet.second )
+ std::pair<bool, bool> bRet = bucket( key ).update( key, func, bAllowInsert );
+ if ( bRet.second )
++m_ItemCounter;
return bRet;
}
CDS_DEPRECATED("ensure() is deprecated, use update()")
std::pair<bool, bool> ensure( K const& key, Func func )
{
- std::pair<bool, bool> bRet = bucket( key ).ensure( key, func );
- if ( bRet.first && bRet.second )
- ++m_ItemCounter;
- return bRet;
+ return update( key, func, true );
}
//@endcond