Remove old VC++ stdext::hash_map from tests
authorkhizmax <libcds.dev@gmail.com>
Sun, 2 Nov 2014 14:41:27 +0000 (17:41 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 2 Nov 2014 14:41:27 +0000 (17:41 +0300)
tests/unit/map2/std_hash_map.h [deleted file]
tests/unit/map2/std_hash_map_gcc.h
tests/unit/map2/std_hash_map_vc.h [deleted file]
tests/unit/map2/std_map.h [new file with mode: 0644]
tests/unit/map2/std_map_gcc.h [deleted file]

diff --git a/tests/unit/map2/std_hash_map.h b/tests/unit/map2/std_hash_map.h
deleted file mode 100644 (file)
index f0e1855..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDSUNIT_STD_HASH_MAP_H
-#define __CDSUNIT_STD_HASH_MAP_H
-
-#if CDS_COMPILER == CDS_COMPILER_MSVC
-#   include "map2/std_hash_map_vc.h"
-#elif CDS_COMPILER == CDS_COMPILER_GCC || CDS_COMPILER == CDS_COMPILER_CLANG
-#   include "map2/std_hash_map_gcc.h"
-#else
-#   error "unordered_map is undefined for this compiler"
-#endif
-
-#endif // #ifndef __CDSUNIT_STD_HASH_MAP_H
index 5cb7ac81b63d99ffb7650c45007302bce715f139..e3984b748bcc38e49ffea4c5b2462ea7b7e6a7be 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <mutex>    //unique_lock
 #include <unordered_map>
-#include <functional>   // ref
+//#include <functional>   // ref
 
 namespace map2 {
 
diff --git a/tests/unit/map2/std_hash_map_vc.h b/tests/unit/map2/std_hash_map_vc.h
deleted file mode 100644 (file)
index 9acb49a..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDSUNIT_STD_HASH_MAP_VC_H
-#define __CDSUNIT_STD_HASH_MAP_VC_H
-
-#include <hash_map>
-#include <functional>   // ref
-#include <mutex>    //unique_lock
-
-namespace map2 {
-    template <typename Key, typename Value, typename Lock, class Alloc = CDS_DEFAULT_ALLOCATOR>
-    class StdHashMap: public stdext::hash_map<Key, Value, stdext::hash_compare<Key, std::less<Key> >, Alloc>
-    {
-    public:
-        Lock m_lock;
-        typedef std::unique_lock<Lock> AutoLock;
-        typedef stdext::hash_map<Key, Value, stdext::hash_compare<Key, std::less<Key> >, Alloc>   base_class;
-    public:
-        typedef typename base_class::mapped_type value_type;
-        typedef typename base_class::value_type  pair_type;
-        typedef size_t      item_counter;
-
-        StdHashMap( size_t nMapSize, size_t nLoadFactor )
-        {}
-
-        bool find( const Key& key )
-        {
-            AutoLock al( m_lock );
-            return base_class::find( key ) != base_class::end();
-        }
-
-        bool insert( const Key& key, const Value& val )
-        {
-            AutoLock al( m_lock );
-            return base_class::insert( base_class::value_type(key, val)).second;
-        }
-
-        template <typename T, typename Func>
-        bool insert( const Key& key, const T& val, Func func )
-        {
-            AutoLock al( m_lock );
-            std::pair<base_class::iterator, bool> pRet = base_class::insert( base_class::value_type(key, Value() ));
-            if ( pRet.second ) {
-                func( pRet.first->second, val );
-                return true;
-            }
-            return false;
-        }
-
-        template <typename T, typename Func>
-        std::pair<bool, bool> ensure( const T& key, Func func )
-        {
-            AutoLock al( m_lock );
-            std::pair<base_class::iterator, bool> pRet = base_class::insert( base_class::value_type(key, Value() ));
-            if ( pRet.second ) {
-                func( true, *pRet.first );
-                return std::make_pair( true, true );
-            }
-            else {
-                func( false, *pRet.first );
-                return std::make_pair( true, false );
-            }
-        }
-
-        bool erase( const Key& key )
-        {
-            AutoLock al( m_lock );
-            return base_class::erase( key ) != 0;
-        }
-
-        template <typename T, typename Func>
-        bool erase( const T& key, Func func )
-        {
-            AutoLock al( m_lock );
-            base_class::iterator it = base_class::find( key );
-            if ( it != base_class::end() ) {
-                func( *it );
-                return base_class::erase( key ) != 0;
-            }
-            return false;
-        }
-
-
-        std::ostream& dump( std::ostream& stm ) { return stm; }
-    };
-}   // namespace map2
-
-#endif  // #ifndef __CDSUNIT_STD_HASH_MAP_VC_H
diff --git a/tests/unit/map2/std_map.h b/tests/unit/map2/std_map.h
new file mode 100644 (file)
index 0000000..2851744
--- /dev/null
@@ -0,0 +1,89 @@
+//$$CDS-header$$
+
+#ifndef __CDSUNIT_STD_MAP_GCC_H
+#define __CDSUNIT_STD_MAP_GCC_H
+
+#include <map>
+#include <mutex>    //unique_lock
+
+namespace map2 {
+
+    template <typename Key, typename Value, typename Lock,
+        class Alloc = typename CDS_DEFAULT_ALLOCATOR::template rebind<std::pair<Key const, Value> >::other
+    >
+    class StdMap: public std::map<Key, Value, std::less<Key>, Alloc>
+    {
+        Lock m_lock;
+        typedef std::unique_lock<Lock> scoped_lock;
+        typedef std::map<Key, Value, std::less<Key>, Alloc> base_class;
+    public:
+        typedef typename base_class::mapped_type value_type;
+        typedef typename base_class::value_type  pair_type;
+        typedef size_t      item_counter;
+
+        StdMap( size_t nMapSize, size_t nLoadFactor )
+        {}
+
+        bool find( const Key& key )
+        {
+            scoped_lock al( m_lock );
+            return base_class::find( key ) != base_class::end();
+        }
+
+        bool insert( const Key& key, const Value& val )
+        {
+            scoped_lock al( m_lock );
+            return base_class::insert( typename base_class::value_type(key, val)).second;
+        }
+
+        template <typename T, typename Func>
+        bool insert( const Key& key, const T& val, Func func )
+        {
+            scoped_lock al( m_lock );
+            std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
+            if ( pRet.second ) {
+                func( pRet.first->second, val );
+                return true;
+            }
+            return false;
+        }
+
+        template <typename T, typename Func>
+        std::pair<bool, bool> ensure( const T& key, Func func )
+        {
+            scoped_lock al( m_lock );
+            std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
+            if ( pRet.second ) {
+                func( true, *pRet.first );
+                return std::make_pair( true, true );
+            }
+            else {
+                func( false, *pRet.first );
+                return std::make_pair( true, false );
+            }
+        }
+
+        bool erase( const Key& key )
+        {
+            scoped_lock al( m_lock );
+            return base_class::erase( key ) != 0;
+        }
+
+        template <typename T, typename Func>
+        bool erase( const T& key, Func func )
+        {
+            scoped_lock al( m_lock );
+            typename base_class::iterator it = base_class::find( key );
+            if ( it != base_class::end() ) {
+                func( (*it) );
+                base_class::erase( it );
+                return true;
+            }
+            return false;
+        }
+
+        std::ostream& dump( std::ostream& stm ) { return stm; }
+    };
+}   // namespace map
+
+#endif  // #ifndef __CDSUNIT_STD_MAP_GCC_H
diff --git a/tests/unit/map2/std_map_gcc.h b/tests/unit/map2/std_map_gcc.h
deleted file mode 100644 (file)
index c798c9c..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDSUNIT_STD_MAP_GCC_H
-#define __CDSUNIT_STD_MAP_GCC_H
-
-#include <map>
-#include <functional>   // ref
-#include <mutex>    //unique_lock
-
-namespace map2 {
-
-    template <typename Key, typename Value, typename Lock,
-        class Alloc = typename CDS_DEFAULT_ALLOCATOR::template rebind<std::pair<Key const, Value> >::other
-    >
-    class StdMap: public std::map<Key, Value, std::less<Key>, Alloc>
-    {
-        Lock m_lock;
-        typedef std::unique_lock<Lock> AutoLock;
-        typedef std::map<Key, Value, std::less<Key>, Alloc> base_class;
-    public:
-        typedef typename base_class::mapped_type value_type;
-        typedef typename base_class::value_type  pair_type;
-        typedef size_t      item_counter;
-
-        StdMap( size_t nMapSize, size_t nLoadFactor )
-        {}
-
-        bool find( const Key& key )
-        {
-            AutoLock al( m_lock );
-            return base_class::find( key ) != base_class::end();
-        }
-
-        bool insert( const Key& key, const Value& val )
-        {
-            AutoLock al( m_lock );
-            return base_class::insert( typename base_class::value_type(key, val)).second;
-        }
-
-        template <typename T, typename Func>
-        bool insert( const Key& key, const T& val, Func func )
-        {
-            AutoLock al( m_lock );
-            std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
-            if ( pRet.second ) {
-                func( pRet.first->second, val );
-                return true;
-            }
-            return false;
-        }
-
-        template <typename T, typename Func>
-        std::pair<bool, bool> ensure( const T& key, Func func )
-        {
-            AutoLock al( m_lock );
-            std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
-            if ( pRet.second ) {
-                func( true, *pRet.first );
-                return std::make_pair( true, true );
-            }
-            else {
-                func( false, *pRet.first );
-                return std::make_pair( true, false );
-            }
-        }
-
-        bool erase( const Key& key )
-        {
-            AutoLock al( m_lock );
-            return base_class::erase( key ) != 0;
-        }
-
-        template <typename T, typename Func>
-        bool erase( const T& key, Func func )
-        {
-            AutoLock al( m_lock );
-            typename base_class::iterator it = base_class::find( key );
-            if ( it != base_class::end() ) {
-                func( (*it) );
-                base_class::erase( it );
-                return true;
-            }
-            return false;
-        }
-
-        std::ostream& dump( std::ostream& stm ) { return stm; }
-    };
-}   // namespace map
-
-#endif  // #ifndef __CDSUNIT_STD_MAP_GCC_H