To support this add the following functions to each of DList and Sentinel classes:
These functions returns an iterator/const_iterator to the first node in the list, end() if list is empty.
these functions returns an iterator/const_iterator to the node just after the last node in the linked list.
Iterator/const_iterator classes
The const_iterator and iterators must support the following operations:
iterator advances to next node in list if iterator is not currently at end(). The iterator returned depends if it is prefix or postfix. prefix operator returns iterator to current node. postfix operator returns iterator to node before the increment.
iterator refer to the node "previous" to the linked list. The iterator returned depends if it is prefix or postfix. prefix operator returns iterator to current node. postfix operator returns iterator to node before the decrement.
returns a const reference to data in the node referred to by the iterator.
returns a reference to data in the node referred to by the iterator.
Please implement iterator and const_iterator for both the functions DList and Sentinel classes in C++ code language , thank you!
.
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
To support this add the following functions to each of DList and Senti.docx
1. To support this add the following functions to each of DList and Sentinel classes:
These functions returns an iterator/const_iterator to the first node in the list, end() if list is empty.
these functions returns an iterator/const_iterator to the node just after the last node in the linked
list.
Iterator/const_iterator classes
The const_iterator and iterators must support the following operations:
iterator advances to next node in list if iterator is not currently at end(). The iterator returned
depends if it is prefix or postfix. prefix operator returns iterator to current node. postfix operator
returns iterator to node before the increment.
iterator refer to the node "previous" to the linked list. The iterator returned depends if it is prefix
or postfix. prefix operator returns iterator to current node. postfix operator returns iterator to
node before the decrement.
returns a const reference to data in the node referred to by the iterator.
returns a reference to data in the node referred to by the iterator.
Please implement iterator and const_iterator for both the functions DList and Sentinel classes
in C++ code language , thank you!
#include
<iostream>
template <typename T>
class DList{
struct Node{
T data_;
Node* next_;
Node* prev_;
Node(const T& data=T{},Node* next=nullptr, Node* prev=nullptr){
data_=data;
next_=next;
prev_=prev;
}
};
Node* front_;
Node* back_;
public: