#include <cds/container/striped_map/boost_map.h>
#include <cds/container/striped_hash_map.h>
typedef cds::container::StripedMap<
- boost::container::map< Key, T, std::pair< const Key, T> >
+ boost::container::map< Key, T, std::less<Key> >
> striped_map;
\endcode
</td>
#include <cds/container/striped_hash_map.h>
typedef cds::container::StripedMap<
boost::container::flat_map< Key, T,
- std::less< std::pair< const Key, T> >
+ std::less< std::less<Key> >
>
> striped_map;
\endcode
There are two possibility:
- either your \p MyBestContainer class has native support of bucket's interface;
in this case, you can use default <tt>striped_set::adapt</tt> metafunction;
- - or your \p MyBestContainer class does not support bucket's interface, which means, that you should develop a specialization
+ - or your \p MyBestContainer class does not support bucket's interface; it means you should develop a specialization
<tt>cds::container::striped_set::adapt<MyBestContainer> </tt> metafunction providing necessary interface.
The <tt>striped_set::adapt< Container, Options... ></tt> metafunction has two template argument:
any option from \p Options for its internal use. For example, a \p compare option can be passed to \p adapt
metafunction via \p Options argument of \p %StripedMap declaration.
- See striped_set::adapt metafunction for the description of interface that the bucket container must provide
+ See \p striped_set::adapt metafunction for the description of interface that the bucket container must provide
to be \p %StripedMap compatible.
<b>Copy policy</b>
#include <cds/container/striped_set/adapter.h>
#include <boost/container/flat_map.hpp>
-//#if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION >= 1700
-//# error "boost::container::flat_map is not compatible with MS VC++ 11"
-//#endif
-
//@cond
namespace cds { namespace container {
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
//value_type newItem( key );
- it = m_List.insert( it, value_type( key, mapped_type()) );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()) );
f( *it );
return true;
template <typename K, typename... Args>
bool emplace( K&& key, Args&&... args )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
- if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
- m_List.emplace( it, std::forward<K>(key), std::move( mapped_type( std::forward<Args>(args)... )) );
+ value_type val( key_type( std::forward<K>( key )), mapped_type( std::forward<Args>( args )... ));
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate() );
+ if ( it == m_List.end() || key_comparator()( val.first, it->first ) != 0 ) {
+ m_List.emplace( it, std::move( val ));
return true;
}
return false;
if ( !bAllowInsert )
return std::make_pair( false, false );
- value_type newItem( key, mapped_type() );
- it = m_List.insert( it, newItem );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type() ));
func( true, *it );
return std::make_pair( true, true );
{
std::pair< iterator, bool > pos = find_prev_item( key );
if ( !pos.second ) {
- value_type newItem( key, mapped_type() );
- pos.first = m_List.insert_after( pos.first, newItem );
+ pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() ));
f( *pos.first );
return true;
}
{
std::pair< iterator, bool > pos = find_prev_item( key );
if ( !pos.second ) {
- m_List.emplace_after( pos.first, std::forward<K>(key), std::move( mapped_type( std::forward<Args>(args)... )));
+ m_List.emplace_after( pos.first, key_type( std::forward<K>( key )), mapped_type( std::forward<Args>( args )... ));
return true;
}
return false;
if ( !bAllowInsert )
return std::make_pair( false, false );
- value_type newItem( key, mapped_type() );
- pos.first = m_List.insert_after( pos.first, newItem );
+ pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() ));
func( true, *pos.first );
return std::make_pair( true, true );
}
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
if ( res.second )
f( const_cast<value_type&>(*res.first) );
return res.second;
template <typename Q, typename... Args>
bool emplace( Q&& key, Args&&... args )
{
- std::pair<iterator, bool> res = m_Map.emplace( std::forward<Q>(key), std::move( mapped_type(std::forward<Args>(args)...)) );
+ std::pair<iterator, bool> res = m_Map.emplace( key_type( std::forward<Q>( key )), mapped_type( std::forward<Args>( args )...));
return res.second;
}
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
func( res.second, const_cast<value_type&>(*res.first));
return std::make_pair( true, res.second );
}
else {
- auto it = m_Map.find(key_type( key ));
+ auto it = m_Map.find( key_type( key ));
if ( it == end() )
return std::make_pair( false, false );
func( false, *it );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = m_Map.find( key_type(key) );
+ iterator it = m_Map.find( key_type( key ));
if ( it == m_Map.end() )
return false;
f( const_cast<value_type&>(*it) );
}
template <typename Q, typename Func>
- bool find( Q& val, Func f )
+ bool find( Q& key, Func f )
{
- iterator it = m_Map.find( key_type(val) );
+ iterator it = m_Map.find( key_type( key ));
if ( it == m_Map.end() )
return false;
- f( const_cast<value_type&>(*it), val );
+ f( const_cast<value_type&>(*it), key );
return true;
}
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
- //value_type newItem( key );
- it = m_List.insert( it, value_type( key, mapped_type()) );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()) );
f( *it );
# if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM)
if ( !bAllowInsert )
return std::make_pair( false, false );
- value_type newItem( key, mapped_type() );
- it = m_List.insert( it, newItem );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type() ));
func( true, *it );
# if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM)
++m_nSize;
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
if ( res.second )
f( *res.first );
return res.second;
template <typename Q, typename... Args>
bool emplace( Q&& key, Args&&... args )
{
- std::pair<iterator, bool> res = m_Map.emplace( std::forward<Q>(key), std::move(mapped_type( std::forward<Args>(args)...)));
+ std::pair<iterator, bool> res = m_Map.emplace( key_type( std::forward<Q>( key )), mapped_type( std::forward<Args>( args )...));
return res.second;
}
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
func( res.second, *res.first );
return std::make_pair( true, res.second );
}
else {
- auto it = m_Map.find(key_type( key ));
+ auto it = m_Map.find( key_type( key ));
if ( it == end() )
return std::make_pair( false, false );
func( false, *it );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = m_Map.find( key_type(key) );
+ iterator it = m_Map.find( key_type( key ));
if ( it == m_Map.end() )
return false;
f( *it );
}
template <typename Q, typename Func>
- bool find( Q& val, Func f )
+ bool find( Q& key, Func f )
{
- iterator it = m_Map.find( key_type(val) );
+ iterator it = m_Map.find( key_type( key ));
if ( it == m_Map.end() )
return false;
- f( *it, val );
+ f( *it, key );
return true;
}
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
if ( res.second )
f( *res.first );
return res.second;
template <typename Q, typename... Args>
bool emplace( Q&& key, Args&&... args )
{
- std::pair<iterator, bool> res = m_Map.emplace( std::forward<Q>(key), std::move( mapped_type( std::forward<Args>(args)...)));
+ std::pair<iterator, bool> res = m_Map.emplace( key_type( std::forward<Q>( key )), mapped_type( std::forward<Args>( args )...));
return res.second;
}
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
func( res.second, *res.first );
return std::make_pair( true, res.second );
}
else {
- auto it = m_Map.find(key_type( key ));
+ auto it = m_Map.find( key_type( key ));
if ( it == end() )
return std::make_pair( false, false );
func( false, *it );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = m_Map.find( key_type(key) );
+ iterator it = m_Map.find( key_type( key ));
if ( it == m_Map.end() )
return false;
f( *it );
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = m_Map.find( key_type(val) );
+ iterator it = m_Map.find( key_type( val ));
if ( it == m_Map.end() )
return false;
f( *it, val );