Fixed iterator issues in set/map
[libcds.git] / cds / intrusive / michael_set_nogc.h
index 983d10c2421e7f161dc42a5566412234c1df605b..9c9ae882e6ed5ca2551117a33a95629b38a74b9f 100644 (file)
@@ -112,11 +112,11 @@ namespace cds { namespace intrusive {
         //@{
         const_iterator begin() const
         {
-            return get_const_begin();
+            return cbegin();
         }
-        const_iterator cbegin()
+        const_iterator cbegin() const
         {
-            return get_const_begin();
+            return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
         }
         //@}
 
@@ -124,26 +124,14 @@ namespace cds { namespace intrusive {
         //@{
         const_iterator end() const
         {
-            return get_const_end();
+            return cend();
         }
-        const_iterator cend()
+        const_iterator cend() const
         {
-            return get_const_end();
+            return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
         }
         //@}
 
-    private:
-        //@cond
-        const_iterator get_const_begin() const
-        {
-            return const_iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count() );
-        }
-        const_iterator get_const_end() const
-        {
-            return const_iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
-        }
-        //@endcond
-
     public:
         /// Initializes hash set
         /** @copydetails cds_intrusive_MichaelHashSet_hp_ctor