#Sales Offer!| Get upto 25% Off:

Start with the DoublyLinkedNode template class that we developed in the tutorial 7. Define
a bi-directional list iterator for doubly-linked lists that satisfies the following template class
specification:
#pragma once
#include “DoublyLinkedNode.h”
template
class 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; // dereference
Iterator& operator++(); // prefix increment
Iterator operator++(int); // postfix increment
Iterator& operator–(); // prefix decrement
Iterator operator–(int); // postfix decrement
bool 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 to
access the current element the iterator is positioned on, the increment operators advance the
iterator to the next element, and the decrement operators take the iterator to the previous
element. The list iterator also defines the equivalence predicates and the four factory
methods: begin(), end(), rbegin(), and rend(). The method begin() returns a new
iterator positioned at the first element, end()returns a new iterator that is positioned after
COS30008 Semester 1, 2020 Dr. Markus Lumpe
3
the last element, rbegin()a new iterator positioned at the last element, and the method
rend() 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 properly
set fLeftmost, fRightmost, and fCurrent. In particular, the constructor has to position
the iterator on the first element of the list. Do not assume that the argument aList passed
to 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 of
DoublyLinkedNodeIterator 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 the
underlying 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 the
last element, or after the last element.
To guarantee to correct behavior of the DoublyLinkedNodeIterator, it must implement
a state machine with three states: BEFORE, DATA, AFTER. The following state transition
diagram illustrates, how DoublyLinkedNodeIterator works:

Found something interesting ?

• On-time delivery guarantee
• PhD-level professional writers
• Free Plagiarism Report

• 100% money-back guarantee
• Absolute Privacy & Confidentiality
• High Quality custom-written papers

Related Model Questions

Feel free to peruse our college and university model questions. If any our our assignment tasks interests you, click to place your order. Every paper is written by our professional essay writers from scratch to avoid plagiarism. We guarantee highest quality of work besides delivering your paper on time.

Grab your Discount!

25% Coupon Code: SAVE25
get 25% !!