Remove old MSVC++ std::map and stdext::hash_map from map tests
authorkhizmax <libcds.dev@gmail.com>
Sun, 2 Nov 2014 14:45:09 +0000 (17:45 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 2 Nov 2014 14:45:09 +0000 (17:45 +0300)
projects/Win/vc12/cds.sln
tests/unit/map2/std_hash_map.h [new file with mode: 0644]
tests/unit/map2/std_hash_map_gcc.h [deleted file]

index aabc38a04aa4c53cfca0a141b8e1b31147c92f85..8789bdbb3fe9578330db68a05f7fa619534edc02 100644 (file)
@@ -71,11 +71,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "map", "map", "{6BB7A27F-FC5
                ..\..\..\tests\unit\map2\map_defs.h = ..\..\..\tests\unit\map2\map_defs.h\r
                ..\..\..\tests\unit\map2\map_types.h = ..\..\..\tests\unit\map2\map_types.h\r
                ..\..\..\tests\unit\map2\std_hash_map.h = ..\..\..\tests\unit\map2\std_hash_map.h\r
-               ..\..\..\tests\unit\map2\std_hash_map_gcc.h = ..\..\..\tests\unit\map2\std_hash_map_gcc.h\r
-               ..\..\..\tests\unit\map2\std_hash_map_vc.h = ..\..\..\tests\unit\map2\std_hash_map_vc.h\r
                ..\..\..\tests\unit\map2\std_map.h = ..\..\..\tests\unit\map2\std_map.h\r
-               ..\..\..\tests\unit\map2\std_map_gcc.h = ..\..\..\tests\unit\map2\std_map_gcc.h\r
-               ..\..\..\tests\unit\map2\std_map_vc.h = ..\..\..\tests\unit\map2\std_map_vc.h\r
        EndProjectSection\r
 EndProject\r
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "set", "set", "{A64449B7-90FB-4E2B-A686-9EFC0E298644}"\r
diff --git a/tests/unit/map2/std_hash_map.h b/tests/unit/map2/std_hash_map.h
new file mode 100644 (file)
index 0000000..0c80896
--- /dev/null
@@ -0,0 +1,99 @@
+//$$CDS-header$$
+
+#ifndef __CDSUNIT_STD_HASH_MAP_GCC_H
+#define __CDSUNIT_STD_HASH_MAP_GCC_H
+
+#include <mutex>    //unique_lock
+#include <unordered_map>
+
+namespace map2 {
+
+    template <typename Key, typename Value, typename Lock,
+        class Alloc = typename CDS_DEFAULT_ALLOCATOR::template rebind<std::pair<Key const, Value> >::other
+    >
+    class StdHashMap
+        : public std::unordered_map<
+            Key, Value
+            , std::hash<Key>
+            , std::equal_to<Key>
+            , Alloc
+        >
+    {
+    public:
+        Lock m_lock;
+        typedef std::unique_lock<Lock> scoped_lock;
+        typedef std::unordered_map<
+            Key, Value
+            , std::hash<Key>
+            , std::equal_to<Key>
+            , Alloc
+        >   base_class;
+    public:
+        typedef typename base_class::mapped_type value_type;
+        typedef size_t      item_counter;
+
+        StdHashMap( 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 );
+                return base_class::erase( key ) != 0;
+            }
+            return false;
+        }
+
+        std::ostream& dump( std::ostream& stm ) { return stm; }
+    };
+}   // namespace map2
+
+#endif  // #ifndef __CDSUNIT_STD_HASH_MAP_GCC_H
diff --git a/tests/unit/map2/std_hash_map_gcc.h b/tests/unit/map2/std_hash_map_gcc.h
deleted file mode 100644 (file)
index e3984b7..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-//$$CDS-header$$
-
-#ifndef __CDSUNIT_STD_HASH_MAP_GCC_H
-#define __CDSUNIT_STD_HASH_MAP_GCC_H
-
-#include <mutex>    //unique_lock
-#include <unordered_map>
-//#include <functional>   // ref
-
-namespace map2 {
-
-    template <typename Key, typename Value, typename Lock,
-        class Alloc = typename CDS_DEFAULT_ALLOCATOR::template rebind<std::pair<Key const, Value> >::other
-    >
-    class StdHashMap
-        : public std::unordered_map<
-            Key, Value
-            , std::hash<Key>
-            , std::equal_to<Key>
-            , Alloc
-        >
-    {
-    public:
-        Lock m_lock;
-        typedef std::unique_lock<Lock> AutoLock;
-        typedef std::unordered_map<
-            Key, Value
-            , std::hash<Key>
-            , std::equal_to<Key>
-            , Alloc
-        >   base_class;
-    public:
-        typedef typename base_class::mapped_type value_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( 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 );
-                return base_class::erase( key ) != 0;
-            }
-            return false;
-        }
-
-        std::ostream& dump( std::ostream& stm ) { return stm; }
-    };
-}   // namespace map2
-
-#endif  // #ifndef __CDSUNIT_STD_HASH_MAP_GCC_H