In this programming problem, you will implement a forward iterator type DoublyLinkedListIterator for a DoublyLinkedList. To understand the DoublyLinkedList's structure, you should read includes/doubly_linked_list.hpp and includes/node.hpp. Understanding the data structure for which you're writing an iterator is important.
After reviewing the structure of DoublyLinkedList, you will implement a forward iterator type DoublyLinkedListIterator for it. The member functions that you are responsible for follow.
Member functions you must implement for DoublyLinkedListIterator
public:
DoublyLinkedListIterator(Node* ptr); Parameterized constructor. Initializes current_ with the value stored in ptr.
T& operator*(); Returns a reference to the data member of the node pointed to by current_.
DoublyLinkedListIterator& operator++(); Pre-increment Operator (invoked as ++obj). This will move current_ one node forward in the sequence of nodes contained within the doubly linked list. This operator will return a self-reference (i.e., return *this) after the increment has been performed.
DoublyLinkedListIterator operator++(int); Post-increment Operator (invoked as obj++). A temporary DoublyLinkedListIterator tmp is initialized with the state of this iterator object. You can accomplish this using the copy constructor in conjunction with *this. After recording the state of this iterator object in tmp, this->current_ is moved forward to the next node in the sequence of nodes contained within the doubly linked list. You then return tmp, which represents the state of this iterator prior to the increment.
bool DoublyLinkedListIterator::operator!=( const DoublyLinkedListIterator& other); Returns true if the two iterators are not pointing to the same node in the sequence; false otherwise.
Member functions provided to you for DoublyLinkedListIterator
public:
DoublyLinkedListIterator() = default; Default constructor.
DoublyLinkedListIterator's data members
private:
Node* current_ Pointer to the node in the doubly linked list's sequence to which the iterator currently "points".
We will only transmit the contents of your doubly_linked_list_iterator.hpp file to the grader. Let's get started!