SlideShare a Scribd company logo
1 of 10
Download to read offline
Please code in C++ and do only the TO DOs and all of them. There are two files.
List.h:
#pragma once
#include // size_t
#include // std::bidirectional_iterator_tag
#include // std::is_same, std::enable_if
template
class List {
private:
struct Node {
Node *next, *prev;
T data;
explicit Node(Node* prev = nullptr, Node* next = nullptr)
: next{next}, prev{prev} {}
explicit Node(const T& data, Node* prev = nullptr, Node* next = nullptr)
: next{next}, prev{prev}, data{data} {}
explicit Node(T&& data, Node* prev = nullptr, Node* next = nullptr)
: next{next}, prev{prev}, data{std::move(data)} {}
};
template
class basic_iterator {
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = T;
using difference_type = ptrdiff_t;
using pointer = pointer_type;
using reference = reference_type;
private:
friend class List;
using Node = typename List::Node;
Node* node;
explicit basic_iterator(Node* ptr) noexcept : node{ptr} {}
explicit basic_iterator(const Node* ptr) noexcept : node{const_cast(ptr)} {}
public:
basic_iterator() { /* TODO */ };
basic_iterator(const basic_iterator&) = default;
basic_iterator(basic_iterator&&) = default;
~basic_iterator() = default;
basic_iterator& operator=(const basic_iterator&) = default;
basic_iterator& operator=(basic_iterator&&) = default;
reference operator*() const {
// TODO
}
pointer operator->() const {
// TODO
}
// Prefix Increment: ++a
basic_iterator& operator++() {
// TODO
}
// Postfix Increment: a++
basic_iterator operator++(int) {
// TODO
}
// Prefix Decrement: --a
basic_iterator& operator--() {
// TODO
}
// Postfix Decrement: a--
basic_iterator operator--(int) {
// TODO
}
bool operator==(const basic_iterator& other) const noexcept {
// TODO
}
bool operator!=(const basic_iterator& other) const noexcept {
// TODO
}
};
public:
using value_type = T;
using size_type = size_t;
using difference_type = ptrdiff_t;
using reference = value_type&;
using const_reference = const value_type&;
using pointer = value_type*;
using const_pointer = const value_type*;
using iterator = basic_iterator;
using const_iterator = basic_iterator;
private:
Node head, tail;
size_type _size;
public:
List() {
// TODO - Don't forget to initialize the list beforehand
}
List( size_type count, const T& value ) {
// TODO - Don't forget initialize the list beforehand
}
explicit List( size_type count ) {
// TODO - Don't forget initialize the list beforehand
}
List( const List& other ) {
// TODO - Don't forget initialize the list beforehand
}
List( List&& other ) {
// TODO - Don't forget initialize the list beforehand
}
~List() {
// TODO
}
List& operator=( const List& other ) {
// TODO
}
List& operator=( List&& other ) noexcept {
// TODO
}
reference front() {
// TODO
}
const_reference front() const {
// TODO
}
reference back() {
// TODO
}
const_reference back() const {
// TODO
}
iterator begin() noexcept {
// TODO
}
const_iterator begin() const noexcept {
// TODO
}
const_iterator cbegin() const noexcept {
// TODO
}
iterator end() noexcept {
// TODO
}
const_iterator end() const noexcept {
// TODO
}
const_iterator cend() const noexcept {
// TODO
}
bool empty() const noexcept {
// TODO
}
size_type size() const noexcept {
// TODO
}
void clear() noexcept {
// TODO
}
iterator insert( const_iterator pos, const T& value ) {
// TODO
}
iterator insert( const_iterator pos, T&& value ) {
// TODO
}
iterator erase( const_iterator pos ) {
// TODO
}
void push_back( const T& value ) {
// TODO
}
void push_back( T&& value ) {
// TODO
}
void pop_back() {
// TODO
}
void push_front( const T& value ) {
// TODO
}
void push_front( T&& value ) {
// TODO
}
void pop_front() {
// TODO
}
/*
You do not need to modify these methods!
These method provide the non-const complement
for the const_iterator methods provided above.
*/
iterator insert( iterator pos, const T & value) {
return insert((const_iterator &) (pos), value);
}
iterator insert( iterator pos, T && value ) {
return insert((const_iterator &) (pos), std::move(value));
}
iterator erase( iterator pos ) {
return erase((const_iterator&)(pos));
}
};
/*
You do not need to modify these methods!
These method provide a overload to compare const and
non-const iterators safely.
*/
namespace {
template
using enable_for_list_iters = typename std::enable_if<
std::is_same<
typename List::value_type>::iterator,
Iter
>{} && std::is_same<
typename List::value_type>::const_iterator,
ConstIter
>{}, T>::type;
}
template
enable_for_list_iters operator==(const Iterator & lhs, const ConstIter & rhs) {
return (const ConstIter &)(lhs) == rhs;
}
template
enable_for_list_iters operator==(const ConstIter & lhs, const Iterator & rhs) {
return (const ConstIter &)(rhs) == lhs;
}
template
enable_for_list_iters operator!=(const Iterator & lhs, const ConstIter & rhs) {
return (const ConstIter &)(lhs) != rhs;
}
template
enable_for_list_iters operator!=(const ConstIter & lhs, const Iterator & rhs) {
return (const ConstIter &)(rhs) != lhs;
}
Queue.h:
#ifndef QUEUE_H
#define QUEUE_H
#include "List.h"
template >
class Queue {
template
friend bool operator==(const Queue&, const Queue&);
public:
// Aliases for accessing data types outside of the class
using container_type = Container;
using value_type = typename Container::value_type;
using size_type = typename Container::size_type;
using reference = typename Container::reference;
using const_reference = typename Container::const_reference;
private:
Container c;
public:
// The constructors, destructor, and assignment operators are done for you
Queue() = default;
Queue(const Queue& other) = default;
Queue(Queue&& other) = default;
~Queue() = default;
Queue& operator=(const Queue& other) = default;
Queue& operator=(Queue&& other) = default;
reference front() { /* TODO */ }
const_reference front() const { /* TODO */ }
reference back() { /* TODO */ }
const_reference back() const { /* TODO */ }
bool empty() const { /* TODO */ }
size_type size() const { /* TODO */ }
void push(const value_type& value) { /* TODO */ }
void push(value_type&& value) { /* TODO */ }
void pop() { /* TODO */ }
};
template
inline bool operator==(const Queue& lhs, const Queue& rhs) { /* TODO */ }
#endif

More Related Content

Similar to C++ LIST AND QUEUE IMPLEMENTATION

#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docxajoy21
 
Please solve the TODO parts include LinkedListcpph tem.pdf
Please solve the TODO parts  include LinkedListcpph tem.pdfPlease solve the TODO parts  include LinkedListcpph tem.pdf
Please solve the TODO parts include LinkedListcpph tem.pdfaggarwalopticalsco
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfjeetumordhani
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfflashfashioncasualwe
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxtodd921
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxLeonardN9WWelchw
 
Алексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляАлексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляSergey Platonov
 
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019corehard_by
 
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdfNeed help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdfactexerode
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docxhoney725342
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxAbhishek Tirkey
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxGauravPandey43518
 

Similar to C++ LIST AND QUEUE IMPLEMENTATION (20)

#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx#include iostream#include d_node.h #include d_nodel.h.docx
#include iostream#include d_node.h #include d_nodel.h.docx
 
Please solve the TODO parts include LinkedListcpph tem.pdf
Please solve the TODO parts  include LinkedListcpph tem.pdfPlease solve the TODO parts  include LinkedListcpph tem.pdf
Please solve the TODO parts include LinkedListcpph tem.pdf
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
 
Mysql1
Mysql1Mysql1
Mysql1
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
Antlr V3
Antlr V3Antlr V3
Antlr V3
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docx
 
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docxGIVEN CODE template -typename T- class DList { private- struct Node {.docx
GIVEN CODE template -typename T- class DList { private- struct Node {.docx
 
Алексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуляАлексей Кутумов, Вектор с нуля
Алексей Кутумов, Вектор с нуля
 
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019Статичный SQL в С++14. Евгений Захаров ➠  CoreHard Autumn 2019
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019
 
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdfNeed help with the TODO's (DONE IN C++) #pragma once   #include -funct.pdf
Need help with the TODO's (DONE IN C++) #pragma once #include -funct.pdf
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 

More from farankureshi

options Alessia belongs to a high-context culture, and Maarten be.pdf
options Alessia belongs to a high-context culture, and Maarten be.pdfoptions Alessia belongs to a high-context culture, and Maarten be.pdf
options Alessia belongs to a high-context culture, and Maarten be.pdffarankureshi
 
Part 3 Installation and Configuration .pdf
Part 3 Installation and Configuration                                .pdfPart 3 Installation and Configuration                                .pdf
Part 3 Installation and Configuration .pdffarankureshi
 
options long words leave an impression of grandeur that complemen.pdf
options long words leave an impression of grandeur that complemen.pdfoptions long words leave an impression of grandeur that complemen.pdf
options long words leave an impression of grandeur that complemen.pdffarankureshi
 
options Please use the attached form to indicate any changes in y.pdf
options Please use the attached form to indicate any changes in y.pdfoptions Please use the attached form to indicate any changes in y.pdf
options Please use the attached form to indicate any changes in y.pdffarankureshi
 
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdf
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdfPart 1 As part of your role as the controller for Lynbrook, Inc., yo.pdf
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdffarankureshi
 
ONLY NEED THE FINAL SLIDES - single step income statement The follo.pdf
ONLY NEED THE FINAL SLIDES - single step income statement  The follo.pdfONLY NEED THE FINAL SLIDES - single step income statement  The follo.pdf
ONLY NEED THE FINAL SLIDES - single step income statement The follo.pdffarankureshi
 
p(pq)(pq)(pq)�(pq)�q.pdf
p(pq)(pq)(pq)�(pq)�q.pdfp(pq)(pq)(pq)�(pq)�q.pdf
p(pq)(pq)(pq)�(pq)�q.pdffarankureshi
 
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdf
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdfOne of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdf
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdffarankureshi
 
Overview This assignment is to be implemented using object-oriented pr.pdf
Overview This assignment is to be implemented using object-oriented pr.pdfOverview This assignment is to be implemented using object-oriented pr.pdf
Overview This assignment is to be implemented using object-oriented pr.pdffarankureshi
 
Our topic this week is emotions and moods. Emotions are short-lived fe.pdf
Our topic this week is emotions and moods. Emotions are short-lived fe.pdfOur topic this week is emotions and moods. Emotions are short-lived fe.pdf
Our topic this week is emotions and moods. Emotions are short-lived fe.pdffarankureshi
 
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdf
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdfOn January 12, 2023, Desmond Doss a professional engineer, moved from .pdf
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdffarankureshi
 
Please answer the following questions in local municipality 1) Do .pdf
Please answer the following questions in local municipality 1) Do .pdfPlease answer the following questions in local municipality 1) Do .pdf
Please answer the following questions in local municipality 1) Do .pdffarankureshi
 
Please answer all questions below (Total10 marks)Input XInp.pdf
Please answer all questions below    (Total10 marks)Input XInp.pdfPlease answer all questions below    (Total10 marks)Input XInp.pdf
Please answer all questions below (Total10 marks)Input XInp.pdffarankureshi
 
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdf
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdfPhase 2. Identify Targets and Run Scans Goal Identify the tools and.pdf
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdffarankureshi
 
Peter is the day-manager at a small proprietor-owned restaurant whic.pdf
Peter is the day-manager at a small proprietor-owned restaurant whic.pdfPeter is the day-manager at a small proprietor-owned restaurant whic.pdf
Peter is the day-manager at a small proprietor-owned restaurant whic.pdffarankureshi
 
PepsiCo As part of our project, we must include a section on the B.pdf
PepsiCo As part of our project, we must include a section on the B.pdfPepsiCo As part of our project, we must include a section on the B.pdf
PepsiCo As part of our project, we must include a section on the B.pdffarankureshi
 
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdf
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdfPart 1 Describe the purpose of a Trial Balance and the steps of how.pdf
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdffarankureshi
 
Part of equation in Economics but I dont understand how it become P.pdf
Part of equation in Economics but I dont understand how it become P.pdfPart of equation in Economics but I dont understand how it become P.pdf
Part of equation in Economics but I dont understand how it become P.pdffarankureshi
 

More from farankureshi (18)

options Alessia belongs to a high-context culture, and Maarten be.pdf
options Alessia belongs to a high-context culture, and Maarten be.pdfoptions Alessia belongs to a high-context culture, and Maarten be.pdf
options Alessia belongs to a high-context culture, and Maarten be.pdf
 
Part 3 Installation and Configuration .pdf
Part 3 Installation and Configuration                                .pdfPart 3 Installation and Configuration                                .pdf
Part 3 Installation and Configuration .pdf
 
options long words leave an impression of grandeur that complemen.pdf
options long words leave an impression of grandeur that complemen.pdfoptions long words leave an impression of grandeur that complemen.pdf
options long words leave an impression of grandeur that complemen.pdf
 
options Please use the attached form to indicate any changes in y.pdf
options Please use the attached form to indicate any changes in y.pdfoptions Please use the attached form to indicate any changes in y.pdf
options Please use the attached form to indicate any changes in y.pdf
 
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdf
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdfPart 1 As part of your role as the controller for Lynbrook, Inc., yo.pdf
Part 1 As part of your role as the controller for Lynbrook, Inc., yo.pdf
 
ONLY NEED THE FINAL SLIDES - single step income statement The follo.pdf
ONLY NEED THE FINAL SLIDES - single step income statement  The follo.pdfONLY NEED THE FINAL SLIDES - single step income statement  The follo.pdf
ONLY NEED THE FINAL SLIDES - single step income statement The follo.pdf
 
p(pq)(pq)(pq)�(pq)�q.pdf
p(pq)(pq)(pq)�(pq)�q.pdfp(pq)(pq)(pq)�(pq)�q.pdf
p(pq)(pq)(pq)�(pq)�q.pdf
 
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdf
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdfOne of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdf
One of Mr. D.I.Y.�s substantial shareholders, Employees Provident Fu.pdf
 
Overview This assignment is to be implemented using object-oriented pr.pdf
Overview This assignment is to be implemented using object-oriented pr.pdfOverview This assignment is to be implemented using object-oriented pr.pdf
Overview This assignment is to be implemented using object-oriented pr.pdf
 
Our topic this week is emotions and moods. Emotions are short-lived fe.pdf
Our topic this week is emotions and moods. Emotions are short-lived fe.pdfOur topic this week is emotions and moods. Emotions are short-lived fe.pdf
Our topic this week is emotions and moods. Emotions are short-lived fe.pdf
 
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdf
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdfOn January 12, 2023, Desmond Doss a professional engineer, moved from .pdf
On January 12, 2023, Desmond Doss a professional engineer, moved from .pdf
 
Please answer the following questions in local municipality 1) Do .pdf
Please answer the following questions in local municipality 1) Do .pdfPlease answer the following questions in local municipality 1) Do .pdf
Please answer the following questions in local municipality 1) Do .pdf
 
Please answer all questions below (Total10 marks)Input XInp.pdf
Please answer all questions below    (Total10 marks)Input XInp.pdfPlease answer all questions below    (Total10 marks)Input XInp.pdf
Please answer all questions below (Total10 marks)Input XInp.pdf
 
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdf
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdfPhase 2. Identify Targets and Run Scans Goal Identify the tools and.pdf
Phase 2. Identify Targets and Run Scans Goal Identify the tools and.pdf
 
Peter is the day-manager at a small proprietor-owned restaurant whic.pdf
Peter is the day-manager at a small proprietor-owned restaurant whic.pdfPeter is the day-manager at a small proprietor-owned restaurant whic.pdf
Peter is the day-manager at a small proprietor-owned restaurant whic.pdf
 
PepsiCo As part of our project, we must include a section on the B.pdf
PepsiCo As part of our project, we must include a section on the B.pdfPepsiCo As part of our project, we must include a section on the B.pdf
PepsiCo As part of our project, we must include a section on the B.pdf
 
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdf
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdfPart 1 Describe the purpose of a Trial Balance and the steps of how.pdf
Part 1 Describe the purpose of a Trial Balance and the steps of how.pdf
 
Part of equation in Economics but I dont understand how it become P.pdf
Part of equation in Economics but I dont understand how it become P.pdfPart of equation in Economics but I dont understand how it become P.pdf
Part of equation in Economics but I dont understand how it become P.pdf
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 

C++ LIST AND QUEUE IMPLEMENTATION

  • 1. Please code in C++ and do only the TO DOs and all of them. There are two files. List.h: #pragma once #include // size_t #include // std::bidirectional_iterator_tag #include // std::is_same, std::enable_if template class List { private: struct Node { Node *next, *prev; T data; explicit Node(Node* prev = nullptr, Node* next = nullptr) : next{next}, prev{prev} {} explicit Node(const T& data, Node* prev = nullptr, Node* next = nullptr) : next{next}, prev{prev}, data{data} {} explicit Node(T&& data, Node* prev = nullptr, Node* next = nullptr) : next{next}, prev{prev}, data{std::move(data)} {} }; template class basic_iterator { public: using iterator_category = std::bidirectional_iterator_tag; using value_type = T; using difference_type = ptrdiff_t; using pointer = pointer_type; using reference = reference_type; private: friend class List;
  • 2. using Node = typename List::Node; Node* node; explicit basic_iterator(Node* ptr) noexcept : node{ptr} {} explicit basic_iterator(const Node* ptr) noexcept : node{const_cast(ptr)} {} public: basic_iterator() { /* TODO */ }; basic_iterator(const basic_iterator&) = default; basic_iterator(basic_iterator&&) = default; ~basic_iterator() = default; basic_iterator& operator=(const basic_iterator&) = default; basic_iterator& operator=(basic_iterator&&) = default; reference operator*() const { // TODO } pointer operator->() const { // TODO } // Prefix Increment: ++a basic_iterator& operator++() { // TODO } // Postfix Increment: a++ basic_iterator operator++(int) { // TODO } // Prefix Decrement: --a
  • 3. basic_iterator& operator--() { // TODO } // Postfix Decrement: a-- basic_iterator operator--(int) { // TODO } bool operator==(const basic_iterator& other) const noexcept { // TODO } bool operator!=(const basic_iterator& other) const noexcept { // TODO } }; public: using value_type = T; using size_type = size_t; using difference_type = ptrdiff_t; using reference = value_type&; using const_reference = const value_type&; using pointer = value_type*; using const_pointer = const value_type*; using iterator = basic_iterator; using const_iterator = basic_iterator; private: Node head, tail; size_type _size; public:
  • 4. List() { // TODO - Don't forget to initialize the list beforehand } List( size_type count, const T& value ) { // TODO - Don't forget initialize the list beforehand } explicit List( size_type count ) { // TODO - Don't forget initialize the list beforehand } List( const List& other ) { // TODO - Don't forget initialize the list beforehand } List( List&& other ) { // TODO - Don't forget initialize the list beforehand } ~List() { // TODO } List& operator=( const List& other ) { // TODO } List& operator=( List&& other ) noexcept { // TODO } reference front() { // TODO } const_reference front() const { // TODO } reference back() { // TODO }
  • 5. const_reference back() const { // TODO } iterator begin() noexcept { // TODO } const_iterator begin() const noexcept { // TODO } const_iterator cbegin() const noexcept { // TODO } iterator end() noexcept { // TODO } const_iterator end() const noexcept { // TODO } const_iterator cend() const noexcept { // TODO } bool empty() const noexcept { // TODO } size_type size() const noexcept { // TODO }
  • 6. void clear() noexcept { // TODO } iterator insert( const_iterator pos, const T& value ) { // TODO } iterator insert( const_iterator pos, T&& value ) { // TODO } iterator erase( const_iterator pos ) { // TODO } void push_back( const T& value ) { // TODO } void push_back( T&& value ) { // TODO } void pop_back() { // TODO } void push_front( const T& value ) { // TODO } void push_front( T&& value ) { // TODO }
  • 7. void pop_front() { // TODO } /* You do not need to modify these methods! These method provide the non-const complement for the const_iterator methods provided above. */ iterator insert( iterator pos, const T & value) { return insert((const_iterator &) (pos), value); } iterator insert( iterator pos, T && value ) { return insert((const_iterator &) (pos), std::move(value)); } iterator erase( iterator pos ) { return erase((const_iterator&)(pos)); } }; /* You do not need to modify these methods! These method provide a overload to compare const and non-const iterators safely.
  • 8. */ namespace { template using enable_for_list_iters = typename std::enable_if< std::is_same< typename List::value_type>::iterator, Iter >{} && std::is_same< typename List::value_type>::const_iterator, ConstIter >{}, T>::type; } template enable_for_list_iters operator==(const Iterator & lhs, const ConstIter & rhs) { return (const ConstIter &)(lhs) == rhs; } template enable_for_list_iters operator==(const ConstIter & lhs, const Iterator & rhs) { return (const ConstIter &)(rhs) == lhs; } template enable_for_list_iters operator!=(const Iterator & lhs, const ConstIter & rhs) { return (const ConstIter &)(lhs) != rhs; } template enable_for_list_iters operator!=(const ConstIter & lhs, const Iterator & rhs) { return (const ConstIter &)(rhs) != lhs;
  • 9. } Queue.h: #ifndef QUEUE_H #define QUEUE_H #include "List.h" template > class Queue { template friend bool operator==(const Queue&, const Queue&); public: // Aliases for accessing data types outside of the class using container_type = Container; using value_type = typename Container::value_type; using size_type = typename Container::size_type; using reference = typename Container::reference; using const_reference = typename Container::const_reference; private: Container c; public: // The constructors, destructor, and assignment operators are done for you Queue() = default; Queue(const Queue& other) = default; Queue(Queue&& other) = default; ~Queue() = default; Queue& operator=(const Queue& other) = default;
  • 10. Queue& operator=(Queue&& other) = default; reference front() { /* TODO */ } const_reference front() const { /* TODO */ } reference back() { /* TODO */ } const_reference back() const { /* TODO */ } bool empty() const { /* TODO */ } size_type size() const { /* TODO */ } void push(const value_type& value) { /* TODO */ } void push(value_type&& value) { /* TODO */ } void pop() { /* TODO */ } }; template inline bool operator==(const Queue& lhs, const Queue& rhs) { /* TODO */ } #endif