#define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
#include <cds/container/striped_set/adapter.h>
-#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008
-# include <cds/container/striped_map/std_hash_map_vc.h>
-#else
-# include <cds/container/striped_map/std_hash_map_std.h>
-#endif
+#include <unordered_map>
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
+//@cond
+namespace cds { namespace container {
+ namespace striped_set {
+
+ // Copy policy for map
+ template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
+ struct copy_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
+ {
+ typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
+ typedef typename map_type::value_type pair_type;
+ typedef typename map_type::iterator iterator;
+
+ void operator()( map_type& map, iterator itWhat )
+ {
+ map.insert( *itWhat );
+ }
+ };
+
+ // Swap policy for map
+ template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
+ struct swap_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
+ {
+ typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
+ typedef typename map_type::value_type pair_type;
+ typedef typename map_type::iterator iterator;
+
+ void operator()( map_type& map, iterator itWhat )
+ {
+ pair_type pair( itWhat->first, typename pair_type::second_type() );
+ std::pair<iterator, bool> res = map.insert( pair );
+ assert( res.second );
+ std::swap( res.first->second, itWhat->second );
+ }
+ };
+
+ // Move policy for map
+ template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
+ struct move_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
+ {
+ typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
+ typedef typename map_type::value_type pair_type;
+ typedef typename map_type::iterator iterator;
+
+ void operator()( map_type& map, iterator itWhat )
+ {
+ map.insert( std::move( *itWhat ) );
+ }
+ };
+ } // namespace striped_set
+}} // namespace cds::container
+
+namespace cds { namespace intrusive { namespace striped_set {
+
+ /// std::unordered_map adapter for hash map bucket
+ template <typename Key, typename T, class Hash, class Pred, class Alloc, typename... Options>
+ class adapt< std::unordered_map< Key, T, Hash, Pred, Alloc>, Options... >
+ {
+ public:
+ typedef std::unordered_map< Key, T, Hash, Pred, Alloc> container_type ; ///< underlying container type
+
+ private:
+ /// Adapted container type
+ class adapted_container: public cds::container::striped_set::adapted_container
+ {
+ public:
+ typedef typename container_type::value_type value_type ; ///< value type stored in the container
+ typedef typename container_type::key_type key_type;
+ typedef typename container_type::mapped_type mapped_type;
+ typedef typename container_type::iterator iterator ; ///< container iterator
+ typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
+
+ static bool const has_find_with = false;
+ static bool const has_erase_with = false;
+
+ private:
+ //@cond
+ typedef typename cds::opt::select<
+ typename cds::opt::value<
+ typename cds::opt::find_option<
+ cds::opt::copy_policy< cds::container::striped_set::move_item >
+ , Options...
+ >::type
+ >::copy_policy
+ , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
+ , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type>
+ , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
+ >::type copy_item;
+ //@endcond
+
+ private:
+ //@cond
+ container_type m_Map;
+ //@endcond
+
+ public:
+ 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() ));
+ 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)...)) );
+ return res.second;
+ }
+
+ template <typename Q, typename Func>
+ std::pair<bool, bool> ensure( const Q& key, Func func )
+ {
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ) );
+ func( res.second, const_cast<value_type&>(*res.first));
+ return std::make_pair( true, res.second );
+ }
+
+ template <typename Q, typename Func>
+ bool erase( const Q& key, Func f )
+ {
+ iterator it = m_Map.find( key_type(key) );
+ if ( it == m_Map.end() )
+ return false;
+ f( const_cast<value_type&>(*it) );
+ m_Map.erase( it );
+ return true;
+ }
+
+ template <typename Q, typename Func>
+ bool find( Q& val, Func f )
+ {
+ iterator it = m_Map.find( key_type(val) );
+ if ( it == m_Map.end() )
+ return false;
+ f( const_cast<value_type&>(*it), val );
+ return true;
+ }
+
+ void clear()
+ {
+ m_Map.clear();
+ }
+
+ iterator begin() { return m_Map.begin(); }
+ const_iterator begin() const { return m_Map.begin(); }
+ iterator end() { return m_Map.end(); }
+ const_iterator end() const { return m_Map.end(); }
+
+ void move_item( adapted_container& /*from*/, iterator itWhat )
+ {
+ assert( m_Map.find( itWhat->first ) == m_Map.end() );
+ copy_item()( m_Map, itWhat );
+ }
+
+ size_t size() const
+ {
+ return m_Map.size();
+ }
+ };
+
+ public:
+ typedef adapted_container type ; ///< Result of \p adapt metafunction
+
+ };
+}}} // namespace cds::intrusive::striped_set
+
+
+//@endcond
+
+#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
+++ /dev/null
-//$$CDS-header$$
-
-#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H
-#define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H
-
-#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
-# error <cds/container/striped_map/std_hash_map.h> must be included instead of <cds/container/striped_map/std_hash_map_std.h> header
-#endif
-
-#include <cds/container/striped_set/adapter.h>
-#include <unordered_map>
-
-//@cond
-namespace cds { namespace container {
- namespace striped_set {
-
- // Copy policy for map
- template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
- struct copy_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
- {
- typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- map.insert( *itWhat );
- }
- };
-
- // Swap policy for map
- template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
- struct swap_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
- {
- typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- pair_type pair( itWhat->first, typename pair_type::second_type() );
- std::pair<iterator, bool> res = map.insert( pair );
- assert( res.second );
- std::swap( res.first->second, itWhat->second );
- }
- };
-
- // Move policy for map
- template <typename Key, typename T, typename Hash, typename Pred, typename Alloc>
- struct move_item_policy< std::unordered_map< Key, T, Hash, Pred, Alloc > >
- {
- typedef std::unordered_map< Key, T, Hash, Pred, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- map.insert( std::move( *itWhat ) );
- }
- };
- } // namespace striped_set
-}} // namespace cds::container
-
-namespace cds { namespace intrusive { namespace striped_set {
-
- /// std::unordered_map adapter for hash map bucket
- template <typename Key, typename T, class Hash, class Pred, class Alloc, typename... Options>
- class adapt< std::unordered_map< Key, T, Hash, Pred, Alloc>, Options... >
- {
- public:
- typedef std::unordered_map< Key, T, Hash, Pred, Alloc> container_type ; ///< underlying container type
-
- private:
- /// Adapted container type
- class adapted_container: public cds::container::striped_set::adapted_container
- {
- public:
- typedef typename container_type::value_type value_type ; ///< value type stored in the container
- typedef typename container_type::key_type key_type;
- typedef typename container_type::mapped_type mapped_type;
- typedef typename container_type::iterator iterator ; ///< container iterator
- typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
-
- static bool const has_find_with = false;
- static bool const has_erase_with = false;
-
- private:
- //@cond
- typedef typename cds::opt::select<
- typename cds::opt::value<
- typename cds::opt::find_option<
- cds::opt::copy_policy< cds::container::striped_set::move_item >
- , Options...
- >::type
- >::copy_policy
- , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
- , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type>
- , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
- >::type copy_item;
- //@endcond
-
- private:
- //@cond
- container_type m_Map;
- //@endcond
-
- public:
- 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() ));
- 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)...)) );
- return res.second;
- }
-
- template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& key, Func func )
- {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key, mapped_type() ) );
- func( res.second, const_cast<value_type&>(*res.first));
- return std::make_pair( true, res.second );
- }
-
- template <typename Q, typename Func>
- bool erase( const Q& key, Func f )
- {
- iterator it = m_Map.find( key_type(key) );
- if ( it == m_Map.end() )
- return false;
- f( const_cast<value_type&>(*it) );
- m_Map.erase( it );
- return true;
- }
-
- template <typename Q, typename Func>
- bool find( Q& val, Func f )
- {
- iterator it = m_Map.find( key_type(val) );
- if ( it == m_Map.end() )
- return false;
- f( const_cast<value_type&>(*it), val );
- return true;
- }
-
- void clear()
- {
- m_Map.clear();
- }
-
- iterator begin() { return m_Map.begin(); }
- const_iterator begin() const { return m_Map.begin(); }
- iterator end() { return m_Map.end(); }
- const_iterator end() const { return m_Map.end(); }
-
- void move_item( adapted_container& /*from*/, iterator itWhat )
- {
- assert( m_Map.find( itWhat->first ) == m_Map.end() );
- copy_item()( m_Map, itWhat );
- }
-
- size_t size() const
- {
- return m_Map.size();
- }
- };
-
- public:
- typedef adapted_container type ; ///< Result of \p adapt metafunction
-
- };
-}}} // namespace cds::intrusive::striped_set
-
-
-//@endcond
-
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_STD_ADAPTER_H
+++ /dev/null
-//$$CDS-header$$
-
-#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H
-#define CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H
-
-#ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_ADAPTER_H
-# error <cds/container/striped_map/std_hash_map.h> must be included instead of <cds/container/striped_map/std_hash_map_vc.h> header
-#endif
-
-#include <cds/container/striped_set/adapter.h>
-#include <hash_map>
-
-//@cond
-namespace cds { namespace container {
- namespace striped_set {
-
- // Copy policy for map
- template <typename Key, typename T, typename Traits, typename Alloc>
- struct copy_item_policy< stdext::hash_map< Key, T, Traits, Alloc > >
- {
- typedef stdext::hash_map< Key, T, Traits, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- std::pair< typename map_type::iterator, bool> res = map.insert( *itWhat );
- assert( res.second ) ; // succesful insert
- }
- };
-
- // Swap policy for map
- template <typename Key, typename T, typename Traits, typename Alloc>
- struct swap_item_policy< stdext::hash_map< Key, T, Traits, Alloc > >
- {
- typedef stdext::hash_map< Key, T, Traits, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- pair_type newVal( itWhat->first, typename pair_type::second_type() );
- std::pair< typename map_type::iterator, bool> res = map.insert( newVal );
- assert( res.second ) ; // succesful insert
- std::swap( res.first->second, itWhat->second );
- }
- };
-
- // Move policy for map
- template <typename Key, typename T, typename Traits, typename Alloc>
- struct move_item_policy< stdext::hash_map< Key, T, Traits, Alloc > >
- {
- typedef stdext::hash_map< Key, T, Traits, Alloc > map_type;
- typedef typename map_type::value_type pair_type;
- typedef typename map_type::iterator iterator;
-
- void operator()( map_type& map, iterator itWhat )
- {
- map.insert( std::move( *itWhat ) );
- }
- };
- } // namespace striped_set
-}} // namespace cds::container
-
-namespace cds { namespace intrusive { namespace striped_set {
-
- /// stdext::hash_map adapter for hash map bucket
- template <typename Key, typename T, class Traits, class Alloc, typename... Options>
- class adapt< stdext::hash_map< Key, T, Traits, Alloc>, Options... >
- {
- public:
- typedef stdext::hash_map< Key, T, Traits, Alloc> container_type ; ///< underlying container type
-
- private:
- /// Adapted container type
- class adapted_container: public cds::container::striped_set::adapted_container
- {
- public:
- typedef typename container_type::value_type value_type ; ///< value type stored in the container
- typedef typename container_type::key_type key_type;
- typedef typename container_type::mapped_type mapped_type;
- typedef typename container_type::iterator iterator ; ///< container iterator
- typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
-
- static bool const has_find_with = false;
- static bool const has_erase_with = false;
-
- private:
- //@cond
- typedef typename cds::opt::select<
- typename cds::opt::value<
- typename cds::opt::find_option<
- cds::opt::copy_policy< cds::container::striped_set::move_item >
- , Options...
- >::type
- >::copy_policy
- , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
- , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type>
- , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
- >::type copy_item;
- //@endcond
-
- private:
- //@cond
- container_type m_Map;
- //@endcond
-
- public:
- 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() ) );
- if ( res.second )
- f( *res.first );
- return res.second;
- }
-
- template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& val, Func func )
- {
- std::pair<iterator, bool> res = m_Map.insert( value_type( val, mapped_type() ));
- func( res.second, *res.first );
- return std::make_pair( true, res.second );
- }
-
- template <typename Q, typename Func>
- bool erase( const Q& key, Func f )
- {
- iterator it = m_Map.find( key_type(key) );
- if ( it == m_Map.end() )
- return false;
- f( *it );
- m_Map.erase( it );
- return true;
- }
-
- template <typename Q, typename Func>
- bool find( Q& val, Func f )
- {
- iterator it = m_Map.find( key_type(val) );
- if ( it == m_Map.end() )
- return false;
- f( *it, val );
- return true;
- }
-
- void clear()
- {
- m_Map.clear();
- }
-
- iterator begin() { return m_Map.begin(); }
- const_iterator begin() const { return m_Map.begin(); }
- iterator end() { return m_Map.end(); }
- const_iterator end() const { return m_Map.end(); }
-
- void move_item( adapted_container& /*from*/, iterator itWhat )
- {
- assert( m_Map.find( itWhat->first ) == m_Map.end() );
- copy_item()( m_Map, itWhat );
- }
-
- size_t size() const
- {
- return m_Map.size();
- }
- };
-
- public:
- typedef adapted_container type ; ///< Result of \p adapt metafunction
-
- };
-}}} // namespace cds::intrusive::striped_set
-
-
-//@endcond
-
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_HASH_MAP_MSVC_ADAPTER_H
#define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
#include <cds/container/striped_set/adapter.h>
-#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600 // MS VC 2008
-# include <cds/container/striped_set/std_hash_set_vc.h>
-#else
-# include <cds/container/striped_set/std_hash_set_std.h>
-#endif
+#include <unordered_set>
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
+//@cond
+namespace cds { namespace container {
+ namespace striped_set {
+
+ // Copy policy for std::unordered_set
+ template <typename T, typename Hash, typename Pred, typename Alloc>
+ struct copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
+ {
+ typedef std::unordered_set< T, Hash, Pred, Alloc > set_type;
+ typedef typename set_type::iterator iterator;
+
+ void operator()( set_type& set, iterator itWhat )
+ {
+ set.insert( *itWhat );
+ }
+ };
+
+ template <typename T, typename Hash, typename Pred, typename Alloc>
+ struct swap_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >: public copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
+ {};
+
+ // Move policy for std::unordered_set
+ template <typename T, typename Hash, typename Pred, typename Alloc>
+ struct move_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
+ {
+ typedef std::unordered_set< T, Hash, Pred, Alloc > set_type;
+ typedef typename set_type::iterator iterator;
+
+ void operator()( set_type& set, iterator itWhat )
+ {
+ set.insert( std::move( *itWhat ) );
+ }
+ };
+
+ } // namespace striped_set
+}} // namespace cds::container
+
+namespace cds { namespace intrusive { namespace striped_set {
+ /// std::unordered_set adapter for hash set bucket
+ template <typename T, class Hash, class Pred, class Alloc, typename... Options>
+ class adapt< std::unordered_set<T, Hash, Pred, Alloc>, Options... >
+ {
+ public:
+ typedef std::unordered_set<T, Hash, Pred, Alloc> container_type ; ///< underlying container type
+
+ private:
+ /// Adapted container type
+ class adapted_container: public cds::container::striped_set::adapted_container
+ {
+ public:
+ typedef typename container_type::value_type value_type ; ///< value type stored in the container
+ typedef typename container_type::iterator iterator ; ///< container iterator
+ typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
+
+ static bool const has_find_with = false;
+ static bool const has_erase_with = false;
+
+ private:
+ //@cond
+ typedef typename cds::opt::select<
+ typename cds::opt::value<
+ typename cds::opt::find_option<
+ cds::opt::copy_policy< cds::container::striped_set::move_item >
+ , Options...
+ >::type
+ >::copy_policy
+ , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
+ , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type> // not defined
+ , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
+ >::type copy_item;
+ //@endcond
+
+ private:
+ //@cond
+ container_type m_Set;
+ //@endcond
+
+ public:
+ template <typename Q, typename Func>
+ bool insert( const Q& val, Func f )
+ {
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ if ( res.second )
+ f( const_cast<value_type&>(*res.first) );
+ return res.second;
+ }
+
+ template <typename... Args>
+ bool emplace( Args&&... args )
+ {
+ std::pair<iterator, bool> res = m_Set.emplace( std::forward<Args>(args)... );
+ return res.second;
+ }
+
+ template <typename Q, typename Func>
+ std::pair<bool, bool> ensure( const Q& val, Func func )
+ {
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ func( res.second, const_cast<value_type&>(*res.first), val );
+ return std::make_pair( true, res.second );
+ }
+
+ template <typename Q, typename Func>
+ bool erase( const Q& key, Func f )
+ {
+ const_iterator it = m_Set.find( value_type(key) );
+ if ( it == m_Set.end() )
+ return false;
+ f( const_cast<value_type&>(*it) );
+ m_Set.erase( it );
+ return true;
+ }
+
+ template <typename Q, typename Func>
+ bool find( Q& val, Func f )
+ {
+ iterator it = m_Set.find( value_type(val) );
+ if ( it == m_Set.end() )
+ return false;
+ f( const_cast<value_type&>(*it), val );
+ return true;
+ }
+
+ /// Clears the container
+ void clear()
+ {
+ m_Set.clear();
+ }
+
+ iterator begin() { return m_Set.begin(); }
+ const_iterator begin() const { return m_Set.begin(); }
+ iterator end() { return m_Set.end(); }
+ const_iterator end() const { return m_Set.end(); }
+
+ void move_item( adapted_container& /*from*/, iterator itWhat )
+ {
+ assert( m_Set.find( *itWhat ) == m_Set.end() );
+ copy_item()( m_Set, itWhat );
+ }
+
+ size_t size() const
+ {
+ return m_Set.size();
+ }
+ };
+
+ public:
+ typedef adapted_container type ; ///< Result of \p adapt metafunction
+ };
+}}} // namespace cds::intrusive::striped_set
+
+
+//@endcond
+
+#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
+++ /dev/null
-//$$CDS-header$$
-
-#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H
-#define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H
-
-#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
-# error <cds/container/striped_set/std_hash_set.h> must be included instead of <cds/container/striped_set/std_hash_set_std.h> header
-#endif
-
-#include <cds/container/striped_set/adapter.h>
-#include <unordered_set>
-
-//@cond
-namespace cds { namespace container {
- namespace striped_set {
-
- // Copy policy for std::unordered_set
- template <typename T, typename Hash, typename Pred, typename Alloc>
- struct copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
- {
- typedef std::unordered_set< T, Hash, Pred, Alloc > set_type;
- typedef typename set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( *itWhat );
- }
- };
-
- template <typename T, typename Hash, typename Pred, typename Alloc>
- struct swap_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >: public copy_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
- {};
-
- // Move policy for std::unordered_set
- template <typename T, typename Hash, typename Pred, typename Alloc>
- struct move_item_policy< std::unordered_set< T, Hash, Pred, Alloc > >
- {
- typedef std::unordered_set< T, Hash, Pred, Alloc > set_type;
- typedef typename set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( std::move( *itWhat ) );
- }
- };
-
- } // namespace striped_set
-}} // namespace cds::container
-
-namespace cds { namespace intrusive { namespace striped_set {
- /// std::unordered_set adapter for hash set bucket
- template <typename T, class Hash, class Pred, class Alloc, typename... Options>
- class adapt< std::unordered_set<T, Hash, Pred, Alloc>, Options... >
- {
- public:
- typedef std::unordered_set<T, Hash, Pred, Alloc> container_type ; ///< underlying container type
-
- private:
- /// Adapted container type
- class adapted_container: public cds::container::striped_set::adapted_container
- {
- public:
- typedef typename container_type::value_type value_type ; ///< value type stored in the container
- typedef typename container_type::iterator iterator ; ///< container iterator
- typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
-
- static bool const has_find_with = false;
- static bool const has_erase_with = false;
-
- private:
- //@cond
- typedef typename cds::opt::select<
- typename cds::opt::value<
- typename cds::opt::find_option<
- cds::opt::copy_policy< cds::container::striped_set::move_item >
- , Options...
- >::type
- >::copy_policy
- , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
- , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type> // not defined
- , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
- >::type copy_item;
- //@endcond
-
- private:
- //@cond
- container_type m_Set;
- //@endcond
-
- public:
- template <typename Q, typename Func>
- bool insert( const Q& val, Func f )
- {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
- if ( res.second )
- f( const_cast<value_type&>(*res.first) );
- return res.second;
- }
-
- template <typename... Args>
- bool emplace( Args&&... args )
- {
- std::pair<iterator, bool> res = m_Set.emplace( std::forward<Args>(args)... );
- return res.second;
- }
-
- template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& val, Func func )
- {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
- func( res.second, const_cast<value_type&>(*res.first), val );
- return std::make_pair( true, res.second );
- }
-
- template <typename Q, typename Func>
- bool erase( const Q& key, Func f )
- {
- const_iterator it = m_Set.find( value_type(key) );
- if ( it == m_Set.end() )
- return false;
- f( const_cast<value_type&>(*it) );
- m_Set.erase( it );
- return true;
- }
-
- template <typename Q, typename Func>
- bool find( Q& val, Func f )
- {
- iterator it = m_Set.find( value_type(val) );
- if ( it == m_Set.end() )
- return false;
- f( const_cast<value_type&>(*it), val );
- return true;
- }
-
- /// Clears the container
- void clear()
- {
- m_Set.clear();
- }
-
- iterator begin() { return m_Set.begin(); }
- const_iterator begin() const { return m_Set.begin(); }
- iterator end() { return m_Set.end(); }
- const_iterator end() const { return m_Set.end(); }
-
- void move_item( adapted_container& /*from*/, iterator itWhat )
- {
- assert( m_Set.find( *itWhat ) == m_Set.end() );
- copy_item()( m_Set, itWhat );
- }
-
- size_t size() const
- {
- return m_Set.size();
- }
- };
-
- public:
- typedef adapted_container type ; ///< Result of \p adapt metafunction
- };
-}}} // namespace cds::intrusive::striped_set
-
-
-//@endcond
-
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_STD_ADAPTER_H
+++ /dev/null
-//$$CDS-header$$
-
-#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H
-#define CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H
-
-#ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_ADAPTER_H
-# error <cds/container/striped_set/std_hash_set.h> must be included instead of <cds/container/striped_set/std_hash_set_vc.h> header
-#endif
-
-#include <cds/container/striped_set/adapter.h>
-#include <hash_set>
-
-//@cond
-namespace cds { namespace container {
- namespace striped_set {
-
- // Copy policy for stdext::hash_set
- template <typename T, typename Traits, typename Alloc>
- struct copy_item_policy< stdext::hash_set< T, Traits, Alloc > >
- {
- typedef stdext::hash_set< T, Traits, Alloc > set_type;
- typedef typename set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( *itWhat );
- }
- };
-
- template <typename T, typename Traits, typename Alloc>
- struct swap_item_policy< stdext::hash_set< T, Traits, Alloc > >: public copy_item_policy< stdext::hash_set< T, Traits, Alloc > >
- {};
-
- // Move policy for stdext::hash_set
- template <typename T, typename Hash, typename Pred, typename Alloc>
- struct move_item_policy< stdext::hash_set< T, Traits, Alloc > >
- {
- typedef stdext::hash_set< T, Traits, Alloc > set_type;
- typedef typename set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( std::move( *itWhat ) );
- }
- };
-
- } // namespace striped_set
-}} // namespace cds::container
-
-namespace cds { namespace intrusive { namespace striped_set {
-
- /// std::unordered_set adapter for hash set bucket
- template <typename T, class Traits, class Alloc, typename... Options>
- class adapt< stdext::hash_set<T, Traits, Alloc>, Options... >
- {
- public:
- typedef stdext::hash_set<T, Traits, Alloc> container_type ; ///< underlying container type
-
- private:
- /// Adapted container type
- class adapted_container: public cds::container::striped_set::adapted_container
- {
- public:
- typedef typename container_type::value_type value_type ; ///< value type stored in the container
- typedef typename container_type::iterator iterator ; ///< container iterator
- typedef typename container_type::const_iterator const_iterator ; ///< container const iterator
-
- static bool const has_find_with = false;
- static bool const has_erase_with = false;
-
- private:
- //@cond
- typedef typename cds::opt::select<
- typename cds::opt::value<
- typename cds::opt::find_option<
- cds::opt::copy_policy< cds::container::striped_set::move_item >
- , Options...
- >::type
- >::copy_policy
- , cds::container::striped_set::copy_item, cds::container::striped_set::copy_item_policy<container_type>
- , cds::container::striped_set::swap_item, cds::container::striped_set::swap_item_policy<container_type> // not defined
- , cds::container::striped_set::move_item, cds::container::striped_set::move_item_policy<container_type>
- >::type copy_item;
- //@endcond
-
- private:
- //@cond
- container_type m_Set;
- //@endcond
-
- public:
-
- template <typename Q, typename Func>
- bool insert( const Q& val, Func f )
- {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
- if ( res.second )
- f( *res.first );
- return res.second;
- }
-
- template <typename Q, typename Func>
- std::pair<bool, bool> ensure( const Q& val, Func func )
- {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
- func( res.second, *res.first, val );
- return std::make_pair( true, res.second );
- }
-
- template <typename Q, typename Func>
- bool erase( const Q& key, Func f )
- {
- iterator it = m_Set.find( value_type(key) );
- if ( it == m_Set.end() )
- return false;
- f( *it );
- m_Set.erase( it );
- return true;
- }
-
- template <typename Q, typename Func>
- bool find( Q& val, Func f )
- {
- iterator it = m_Set.find( value_type(val) );
- if ( it == m_Set.end() )
- return false;
- f( *it, val );
- return true;
- }
-
- /// Clears the container
- void clear()
- {
- m_Set.clear();
- }
-
- iterator begin() { return m_Set.begin(); }
- const_iterator begin() const { return m_Set.begin(); }
- iterator end() { return m_Set.end(); }
- const_iterator end() const { return m_Set.end(); }
-
- void move_item( adapted_container& /*from*/, iterator itWhat )
- {
- assert( m_Set.find( *itWhat ) == m_Set.end() );
- copy_item()( m_Set, itWhat );
- }
-
- size_t size() const
- {
- return m_Set.size();
- }
- };
-
- public:
- typedef adapted_container type ; ///< Result of \p adapt metafunction
-
- };
-}}} // namespace cds::intrusive::striped_set
-
-//@endcond
-
-#endif // #ifndef CDSLIB_CONTAINER_STRIPED_SET_STD_HASH_SET_MSVC_ADAPTER_H
<ClInclude Include="..\..\..\cds\container\striped_map\boost_slist.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_map\boost_unordered_map.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map.h" />\r
- <ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map_std.h" />\r
- <ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map_vc.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_map\std_list.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_map\std_map.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\boost_unordered_set.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\boost_vector.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set.h" />\r
- <ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set_std.h" />\r
- <ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set_vc.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_list.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_set.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_vector.h" />\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set.h">\r
<Filter>Header Files\cds\container\striped_set</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set_std.h">\r
- <Filter>Header Files\cds\container\striped_set</Filter>\r
- </ClInclude>\r
- <ClInclude Include="..\..\..\cds\container\striped_set\std_hash_set_vc.h">\r
- <Filter>Header Files\cds\container\striped_set</Filter>\r
- </ClInclude>\r
<ClInclude Include="..\..\..\cds\container\striped_set\std_list.h">\r
<Filter>Header Files\cds\container\striped_set</Filter>\r
</ClInclude>\r
<ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map.h">\r
<Filter>Header Files\cds\container\striped_map</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map_std.h">\r
- <Filter>Header Files\cds\container\striped_map</Filter>\r
- </ClInclude>\r
- <ClInclude Include="..\..\..\cds\container\striped_map\std_hash_map_vc.h">\r
- <Filter>Header Files\cds\container\striped_map</Filter>\r
- </ClInclude>\r
<ClInclude Include="..\..\..\cds\container\striped_map\std_list.h">\r
<Filter>Header Files\cds\container\striped_map</Filter>\r
</ClInclude>\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_boost_unordered_set.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_boost_vector.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_hashset_std.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_hashset_vc.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_list.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_set.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_slist.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_boost_unordered_set.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_boost_vector.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_hashset_std.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_hashset_vc.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_list.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_set.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_slist.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_hashset_std.cpp">\r
<Filter>container\striped</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_hashset_vc.cpp">\r
- <Filter>container\striped</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_refinable_hashset_list.cpp">\r
<Filter>container\striped</Filter>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_hashset_std.cpp">\r
<Filter>container\striped</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_hashset_vc.cpp">\r
- <Filter>container\striped</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\set\hdr_striped_hashset_list.cpp">\r
<Filter>container\striped</Filter>\r
</ClCompile>\r
#include <cds/container/striped_map.h>
#include <cds/lock/spinlock.h>
-#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
-
namespace map {
namespace {
}
} // namespace map
-
-#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)
#include <cds/container/striped_map.h>
#include <cds/lock/spinlock.h>
-#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
-
namespace map {
namespace {
}
} // namespace map
-
-#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)
#include <cds/container/striped_set.h>
#include <cds/lock/spinlock.h>
-#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
-
namespace set {
namespace {
}
} // namespace set
-#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)
+++ /dev/null
-//$$CDS-header$$
-
-#include "set/hdr_striped_set.h"
-#include <cds/container/striped_set/std_hash_set.h>
-#include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
-
-#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600
-
-namespace stdext {
- inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval)
- {
- return set::StripedSetHdrTest::hash_int()( _Keyval );
- }
-}
-
-namespace set {
-
- namespace {
- typedef stdext::hash_compare<StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > hash_set_t;
-
- struct my_copy_policy {
- typedef stdext::hash_set< StripedSetHdrTest::item, hash_set_t > set_type;
- typedef set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
- }
- };
-
- typedef stdext::hash_set<StripedSetHdrTest::item, hash_set_t > set_t;
- }
-
- void StripedSetHdrTest::Refinable_hashset()
- {
- CPPUNIT_MESSAGE( "cmp");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- ,co::mutex_policy< cc::striped_set::refinable<> >
- > set_cmp;
- test_striped< set_cmp >();
-
- CPPUNIT_MESSAGE( "less");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::less< less<item> >
- > set_less;
- test_striped< set_less >();
-
- CPPUNIT_MESSAGE( "cmpmix");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::less< less<item> >
- > set_cmpmix;
- test_striped< set_cmpmix >();
-
- // Spinlock as lock policy
- CPPUNIT_MESSAGE( "spinlock");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<cds::lock::ReentrantSpin> >
- , co::hash< hash_int >
- , co::less< less<item> >
- > set_spin;
- test_striped< set_spin >();
-
- // Resizing policy
- CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
- {
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
- > set_less_resizing_lf;
- set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024));
- test_striped_with(s);
- }
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- > set_less_resizing_lf16;
- test_striped< set_less_resizing_lf16 >();
-
- CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
- {
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
- > set_less_resizing_sbt;
- set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
- test_striped_with(s);
- }
-
- CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
- > set_less_resizing_sbt16;
- test_striped< set_less_resizing_sbt16 >();
-
- // Copy policy
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::copy_item >
- > set_copy_item;
- test_striped< set_copy_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::swap_item >
- > set_swap_item;
- test_striped< set_swap_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::move_item >
- > set_move_item;
- test_striped< set_move_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
- typedef cc::StripedSet< set_t
- ,co::mutex_policy< cc::striped_set::refinable<> >
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< my_copy_policy >
- > set_special_copy_item;
- test_striped< set_special_copy_item >();
- }
-} // namespace set
-#endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600
#include <cds/container/striped_set.h>
#include <cds/lock/spinlock.h>
-#if !((CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600)
-
namespace set {
namespace {
}
} // namespace set
-#endif // #if !(CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600)
+++ /dev/null
-//$$CDS-header$$
-
-#include "set/hdr_striped_set.h"
-#include <cds/container/striped_set/std_hash_set.h>
-#include <cds/container/striped_set.h>
-#include <cds/lock/spinlock.h>
-
-#if (CDS_COMPILER == CDS_COMPILER_MSVC || (CDS_COMPILER == CDS_COMPILER_INTEL && CDS_OS_INTERFACE == CDS_OSI_WINDOWS)) && _MSC_VER < 1600
-
-namespace stdext {
- inline size_t hash_value(set::StripedSetHdrTest::item const& _Keyval)
- {
- return set::StripedSetHdrTest::hash_int()( _Keyval );
- }
-}
-
-namespace set {
-
- namespace {
- typedef stdext::hash_compare<StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > hash_set_t;
-
- struct my_copy_policy {
- typedef stdext::hash_set< StripedSetHdrTest::item, hash_set_t > set_type;
- typedef set_type::iterator iterator;
-
- void operator()( set_type& set, iterator itWhat )
- {
- set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
- }
- };
-
- typedef stdext::hash_set<StripedSetHdrTest::item, hash_set_t > set_t;
- }
-
- void StripedSetHdrTest::Striped_hashset()
- {
- CPPUNIT_MESSAGE( "cmp");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- ,co::mutex_policy< cc::striped_set::striping<> >
- > set_cmp;
- test_striped< set_cmp >();
-
- CPPUNIT_MESSAGE( "less");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- ,co::mutex_policy< cc::striped_set::striping<> >
- > set_less;
- test_striped< set_less >();
-
- CPPUNIT_MESSAGE( "cmpmix");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::less< less<item> >
- ,co::mutex_policy< cc::striped_set::striping<> >
- > set_cmpmix;
- test_striped< set_cmpmix >();
-
- // Spinlock as lock policy
- CPPUNIT_MESSAGE( "spinlock");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- ,co::mutex_policy< cc::striped_set::striping< cds::lock::Spin > >
- > set_spin;
- test_striped< set_spin >();
-
- // Resizing policy
- CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
- {
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
- > set_less_resizing_lf;
- set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>( 1024 ));
- test_striped_with( s );
- }
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- > set_less_resizing_lf16;
- test_striped< set_less_resizing_lf16 >();
-
- CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024");
- {
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
- > set_less_resizing_sbt;
- set_less_resizing_sbt s( 30, cc::striped_set::single_bucket_size_threshold<0>(1024));
- test_striped_with(s);
- }
-
- CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::less< less<item> >
- , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
- > set_less_resizing_sbt16;
- test_striped< set_less_resizing_sbt16 >();
-
- // Copy policy
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::copy_item >
- > set_copy_item;
- test_striped< set_copy_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::swap_item >
- > set_swap_item;
- test_striped< set_swap_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< cc::striped_set::move_item >
- > set_move_item;
- test_striped< set_move_item >();
-
- CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
- typedef cc::StripedSet< set_t
- , co::hash< hash_int >
- , co::compare< cmp<item> >
- , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
- , co::copy_policy< my_copy_policy >
- > set_special_copy_item;
- test_striped< set_special_copy_item >();
- }
-
-} // namespace set
-#endif // #if CDS_COMPILER == CDS_COMPILER_MSVC && CDS_COMPILER_VERSION < 1600