Problem 1:Start with the DoublyLinkedNode template class that we developed in the tutorial 7. Definea bi-directional list iterator for doubly-linked lists that satisfies the following template classspecification:#pragma once#include “DoublyLinkedNode.h”templateclass DoublyLinkedNodeIterator{private:enum IteratorStates { BEFORE, DATA , AFTER };IteratorStates fState;typedef DoublyLinkedNode Node;const Node* fLeftmost;const Node* fRightmost;const Node* fCurrent;public:typedef DoublyLinkedNodeIterator Iterator;DoublyLinkedNodeIterator( const Node& aList );const DataType& operator*() const; // dereferenceIterator& operator++(); // prefix incrementIterator operator++(int); // postfix incrementIterator& operator–(); // prefix decrementIterator operator–(int); // postfix decrementbool operator==( const Iterator& aOtherIter ) const;bool operator!=( const Iterator& aOtherIter ) const;Iterator begin() const;Iterator end() const;Iterator rbegin() const;Iterator rend() const;};The bi-directional list iterator implements the standard operators for iterators: dereference toaccess the current element the iterator is positioned on, the increment operators advance theiterator to the next element, and the decrement operators take the iterator to the previouselement. The list iterator also defines the equivalence predicates and the four factorymethods: begin(), end(), rbegin(), and rend(). The method begin() returns a newiterator positioned at the first element, end()returns a new iterator that is positioned afterCOS30008 Semester 1, 2020 Dr. Markus Lumpe3the last element, rbegin()a new iterator positioned at the last element, and the methodrend() returns a new list iterator positioned before the first element of the doubly-linked list.Implement the list iterator. Please note that the constructor of the list iterator has to properlyset fLeftmost, fRightmost, and fCurrent. In particular, the constructor has to positionthe iterator on the first element of the list. Do not assume that the argument aList passedto the constructor denotes the first or last element of a doubly-linked list.An iterator must not change the underlying collection. However, in the case ofDoublyLinkedNodeIterator we need a special marker to denote, whether the iterator is“before” the first list element or “after” the last list element. Since we cannot change theunderlying list, we need to add state to the iterator. Using the iterator state (i.e., fState)we can now clearly mark when the iterator is before the first element, within the first and thelast element, or after the last element.To guarantee to correct behavior of the DoublyLinkedNodeIterator, it must implementa state machine with three states: BEFORE, DATA, AFTER. The following state transitiondiagram illustrates, how DoublyLinkedNodeIterator works:

 
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

 

"Are you looking for this answer? We can Help click Order Now"