Question: C++ Write the following linked list called RecentList , along with const_iterator and iterator for the list. This type of linked lists ensures that nodes
C++
Write the following linked list called RecentList, along with const_iterator and iterator for the list. This type of linked lists ensures that nodes that were recently accessed are placed towards the front of the list
The RecentList is a templated linked list where each node stores an instance of an unspecified data type (called T below). This linked list must be doubly linked and perform operations as described. Other than that the specifics of the implementation is left up to you.
You may assume the following operators are valid for the unspecified data type:
- ==
- !=
- =
The RecentList must have the following member functions:
| template | |
| class RecentList{ | |
| struct Node{ | |
| Node(const T& data=T{},Node* nx=nullptr,Node* pr=nullptr){ | |
| } | |
| }; | |
| public: | |
| class const_iterator{ | |
| public: | |
| const_iterator(){} | |
| const_iterator operator++(){} | |
| const_iterator operator++(int){} | |
| const_iterator operator--(){} | |
| const_iterator operator--(int){} | |
| bool operator==(const_iterator rhs){} | |
| bool operator!=(const_iterator rhs){} | |
| const T& operator*()const{} | |
| }; | |
| class iterator:public const_iterator{ | |
| public: | |
| iterator(){} | |
| iterator operator++(){} | |
| iterator operator++(int){} | |
| iterator operator--(){} | |
| iterator operator--(int){} | |
| T& operator*(){} | |
| const T& operator*()const{} | |
| }; | |
| RecentList(); | |
| ~RecentList(); | |
| RecentList(const RecentList& rhs); | |
| RecentList& operator=(const RecentList& rhs); | |
| RecentList(RecentList&& rhs); | |
| RecentList& operator=(RecentList&& rhs); | |
| iterator begin(){} | |
| iterator end(){} | |
| const_iterator cbegin() const{} | |
| const_iterator cend() const{} | |
| void insert(const T& data); | |
| iterator search(const T& data); | |
| iterator erase(iterator it); | |
| iterator erase(iterator first, iterator last); | |
| bool empty() const; | |
| int size() const; | |
| }; | |
| template | |
| RecentList | |
| } | |
| template | |
| RecentList | |
| } | |
| template | |
| RecentList | |
| } | |
| template | |
| RecentList | |
| } | |
| template | |
| RecentList | |
| } | |
| template | |
| RecentList | |
| } | |
| template | |
| void RecentList | |
| } | |
| template | |
| typename RecentList | |
| } | |
| template | |
| typename RecentList | |
| } | |
| template | |
| typename RecentList | |
| } | |
| template | |
| bool RecentList | |
| } | |
| template | |
| int RecentList | |
| } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
