]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/containers/safe_iterator.tpp
import stlplus 3.7
[chaz/yoink] / src / stlplus / containers / safe_iterator.tpp
index 14d89b992b30b7af42868fd3a2411c222d93bba9..4bbf9b8b18029102df2387109f15389b190ff07d 100644 (file)
@@ -17,18 +17,10 @@ namespace stlplus
     safe_iterator_body(const O* owner, N* node) throw() : \r
       m_owner(owner), m_node(node), m_count(1)\r
       {\r
-//         std::cerr << "constructing " \r
-//                   << std::hex << ((unsigned long)this) \r
-//                   << " => " << ((unsigned long)m_owner) << ":" << ((unsigned long)m_node)\r
-//                   << ":" << std::dec << m_count << std::endl;\r
       }\r
 \r
     ~safe_iterator_body(void) throw()\r
       {\r
-//         std::cerr << "destroying " \r
-//                   << std::hex << ((unsigned long)this) \r
-//                   << " => " << ((unsigned long)m_owner) << ":" << ((unsigned long)m_node)\r
-//                   << ":" << std::dec << m_count << std::endl;\r
         m_owner = 0;\r
         m_node = 0;\r
       }\r
@@ -41,19 +33,11 @@ namespace stlplus
     void increment(void)\r
       {\r
         ++m_count;\r
-//         std::cerr << "incremented " \r
-//                   << std::hex << ((unsigned long)this) \r
-//                   << " => " << ((unsigned long)m_owner) << ":" << ((unsigned long)m_node)\r
-//                   << ":" << std::dec << m_count << std::endl;\r
       }\r
 \r
     bool decrement(void)\r
       {\r
         --m_count;\r
-//         std::cerr << "decremented " \r
-//                   << std::hex << ((unsigned long)this) \r
-//                   << " => " << ((unsigned long)m_owner) << ":" << ((unsigned long)m_node)\r
-//                   << ":" << std::dec << m_count << std::endl;\r
         return m_count == 0;\r
       }\r
 \r
@@ -74,13 +58,13 @@ namespace stlplus
 \r
     bool equal(const safe_iterator_body<O,N>* right) const throw()\r
       {\r
-//        return m_node == right->m_node;\r
-        return compare(right) == 0;\r
+        return m_node == right->m_node;\r
       }\r
 \r
     int compare(const safe_iterator_body<O,N>* right) const throw()\r
       {\r
-        return ((long)m_node) - ((long)right->m_node);\r
+        if (m_node == right->m_node) return 0;\r
+        return (m_node < right->m_node) ? -1 : 1;\r
       }\r
 \r
     bool null(void) const throw()\r
@@ -112,21 +96,21 @@ namespace stlplus
     void assert_valid(void) const throw(null_dereference,end_dereference)\r
       {\r
         if (null())\r
-          throw null_dereference("stlplus::safe_iterator");\r
+          throw null_dereference("stlplus::safe_iterator: dereferencing null iterator");\r
         if (end())\r
-          throw end_dereference("stlplus::safe_iterator");\r
+          throw end_dereference("stlplus::safe_iterator: dereferencing end iterator");\r
       }\r
 \r
     void assert_non_null(void) const throw(null_dereference)\r
       {\r
         if (null())\r
-          throw null_dereference("stlplus::safe_iterator");\r
+          throw null_dereference("stlplus::safe_iterator: dereferencing null iterator");\r
       }\r
 \r
     void assert_owner(const O* owner) const throw(wrong_object)\r
       {\r
         if (owner != m_owner)\r
-          throw wrong_object("stlplus::safe_iterator");\r
+          throw wrong_object("stlplus::safe_iterator: using iterator with wrong object");\r
       }\r
   };\r
 \r
@@ -313,13 +297,13 @@ namespace stlplus
   template<typename O, typename N>\r
   bool safe_iterator<O,N>::equal(const safe_iterator<O,N>& right) const throw()\r
   {\r
-    return compare(right) == 0;\r
+    if (m_body == right.m_body) return true;\r
+    return m_body->equal(right.m_body);\r
   }\r
 \r
   template<typename O, typename N>\r
   int safe_iterator<O,N>::compare(const safe_iterator<O,N>& right) const throw()\r
   {\r
-    if (m_body == right.m_body) return 0;\r
     return m_body->compare(right.m_body);\r
   }\r
 \r
This page took 0.022215 seconds and 4 git commands to generate.