add bidirectional iterator methods
authorTJ <hacker@iam.tj>
Sun, 12 Apr 2015 12:55:45 +0000 (13:55 +0100)
committerTJ <hacker@iam.tj>
Sun, 12 Apr 2015 12:55:45 +0000 (13:55 +0100)
GenericStorageContainerTemplateImpl.hpp

index 2aade09..434a8f3 100644 (file)
@@ -198,6 +198,8 @@ namespace tj
       iterator<is_const_iterator> ( StorageClass<T>& node) : __node(node) {};
       iterator<is_const_iterator> (const iterator<is_const_iterator>& copy) : __node(copy.__node) {}; // copy constructor
 
+      // ForwardIterator methods
+
       // postfix increment operator
       self_type operator++()
       {
@@ -209,10 +211,28 @@ namespace tj
       // prefix increment operator
       self_type operator++(int unused)
       {
-        __node = __node->get_next();
+        __node = __node.get_next();
         return *this;
       }
 
+      // BidirectionalIterator methods
+
+      // postfix decrement
+      self_type operator--()
+      {
+        self_type original = *this; // keep reference to value that is to be returned
+        this->__node.get_previous();
+        return original;
+      };
+
+      // prefix decrement
+      self_type operator--(int unused)
+      {
+        __node = __node->get_previous();
+        return *this;
+      };
+
+      // Comparison methods
       bool operator==(const self_type& right_hand_side)
       {
         return __node == right_hand_side.__node;