SlideShare a Scribd company logo

C++ pleae Your welcome DoublyLinkedList thisgthea.pdf

J
jaipur2

C++ pleae /// Your welcome DoublyLinkedList() { this->head_ = nullptr; this->tail_ = nullptr; this->size_ = 0; } /// Copy Constructor DoublyLinkedList(DoublyLinkedList& other) { for (auto it = other.begin(); it!= other.end(); ++it) { this->push_back(*it); } } /// DTOR: Your welcome ~DoublyLinkedList() { this->clear(); } /** * Clear the list and assign the same value, count times. * If count was 5, T was int, and value was 3, * we'd end up with a list like {3, 3, 3, 3, 3} */ void assign(size_t count, const T& value) { this->clear(); for (size_t i = 0; i < count; ++i) { this->push_back(value); } } /** * Clear the list and assign values from another list. * The 'first' iterator points to the first item copied from the other list. * The 'last' iterator points to the last item copied from the other list. * * Example: * Suppose we have a source list like {8, 4, 3, 2, 7, 1} * Suppose first points to the 4 * Suppose last points to the 7 * We should end up with our list becoming: {4, 3, 2, 7} * * If the user code sends out-of-order iterators, * just copy from 'first' to the end of the source list * Example: first=7, last=4 from the list above would give us: * {7, 1} */ void assign(Iterator first, Iterator last) { this->clear(); Iterator it; for (it = first; it!= last; ++it) { this->push_back(*it); } if (it != nullptr && it->next == last) { this->push_back(*last); } } /// Return a pointer to the head node, if any Node<T>* head() { return head_; } /// Return a pointer to the tail node, if any Node<T>* tail() { return tail_; } /** * Return an iterator that points to the head of our list */ Iterator begin() { return Iterator(this->head_); } /** * Return an iterator that points to the last element (tail) of our list */ Iterator last() { return Iterator(this->tail_); } /** * Should return an iterator that represents being past the end of our nodes, * or just that we are finished. * You can make this a nullptr or use some other scheme of your choosing, * as long as it works with the logic of the rest of your implementations. */ Iterator end() { return Iterator(nullptr); } /** * Returns true if our list is empty */ bool empty() const { return this->size_ == 0; } /** * Returns the current size of the list * Should finish in constant time! * (keep track of the size elsewhere) */ size_t size() const { return 0; } /** * Clears our entire list, making it empty * Remember: All removal operations should be memory-leak free. */ void clear() { size_ = 0; Node<T> *node = this->head_; while (node!= nullptr) { Node<T> *next = node->next_; delete node; node = next; } this->head_ = nullptr; this->tail_ = nullptr; } /** * Insert an element after the node pointed to by the pos Iterator * * If the list is currently empty, * ignore the iterator and just make the new node at the head/tail (list of length 1). * * If the incoming iterator is this->end(), insert the element at the tail * * Should return an iterator that points to the newly added node * * To avoid repeated code, it.

1 of 5
Download to read offline
C++ pleae
/// Your welcome
DoublyLinkedList()
{
this->head_ = nullptr;
this->tail_ = nullptr;
this->size_ = 0;
}
/// Copy Constructor
DoublyLinkedList(DoublyLinkedList& other)
{
for (auto it = other.begin(); it!= other.end(); ++it) {
this->push_back(*it);
}
}
/// DTOR: Your welcome
~DoublyLinkedList()
{
this->clear();
}
/**
* Clear the list and assign the same value, count times.
* If count was 5, T was int, and value was 3,
* we'd end up with a list like {3, 3, 3, 3, 3}
*/
void assign(size_t count, const T& value)
{
this->clear();
for (size_t i = 0; i < count; ++i) {
this->push_back(value);
}
}
/**
* Clear the list and assign values from another list.
* The 'first' iterator points to the first item copied from the other list.
* The 'last' iterator points to the last item copied from the other list.
*
* Example:
* Suppose we have a source list like {8, 4, 3, 2, 7, 1}
* Suppose first points to the 4
* Suppose last points to the 7
* We should end up with our list becoming: {4, 3, 2, 7}
*
* If the user code sends out-of-order iterators,
* just copy from 'first' to the end of the source list
* Example: first=7, last=4 from the list above would give us:
* {7, 1}
*/
void assign(Iterator first, Iterator last)
{
this->clear();
Iterator it;
for (it = first; it!= last; ++it) {
this->push_back(*it);
}
if (it != nullptr && it->next == last) {
this->push_back(*last);
}
}
/// Return a pointer to the head node, if any
Node<T>* head() { return head_; }
/// Return a pointer to the tail node, if any
Node<T>* tail() { return tail_; }
/**
* Return an iterator that points to the head of our list
*/
Iterator begin()
{
return Iterator(this->head_);
}
/**
* Return an iterator that points to the last element (tail) of our list
*/
Iterator last()
{
return Iterator(this->tail_);
}
/**
* Should return an iterator that represents being past the end of our nodes,
* or just that we are finished.
* You can make this a nullptr or use some other scheme of your choosing,
* as long as it works with the logic of the rest of your implementations.
*/
Iterator end()
{
return Iterator(nullptr);
}
/**
* Returns true if our list is empty
*/
bool empty() const
{
return this->size_ == 0;
}
/**
* Returns the current size of the list
* Should finish in constant time!
* (keep track of the size elsewhere)
*/
size_t size() const
{
return 0;
}
/**
* Clears our entire list, making it empty
* Remember: All removal operations should be memory-leak free.
*/
void clear()
{
size_ = 0;
Node<T> *node = this->head_;
while (node!= nullptr) {
Node<T> *next = node->next_;
delete node;
node = next;
}
this->head_ = nullptr;
this->tail_ = nullptr;
}
/**
* Insert an element after the node pointed to by the pos Iterator
*
* If the list is currently empty,
* ignore the iterator and just make the new node at the head/tail (list of length 1).
*
* If the incoming iterator is this->end(), insert the element at the tail
*
* Should return an iterator that points to the newly added node
*
* To avoid repeated code, it might be a good idea to have other methods
* rely on this one.
*/
Iterator insert_after(Iterator pos, const T& value)
{
return Iterator(nullptr, nullptr, nullptr);
}
/**
* Insert a new element after the index pos.
* Should work with an empty list.
*
* Should return an iterator pointing to the newly created node
*
* To reduce repeated code, you may want to simply find
* an iterator to the node at the pos index, then
* send it to the other overload of this method.
*/
Iterator insert_after(size_t pos, const T& value)
{
return Iterator(nullptr, nullptr, nullptr);
}
/**
* Erase the node pointed to by the Iterator's cursor.
*
* If the 'pos' iterator does not point to a valid node,
* throw an std::range_error
*
* Return an iterator to the node AFTER the one we erased,
* or this->end() if we just erased the tail
*/
Iterator erase(Iterator pos)
{
return Iterator(nullptr, nullptr, nullptr);
}
/**
* Add an element just after the one pointed to by the 'pos' iterator
*
* Should return an iterator pointing to the newly created node
*/
Iterator push_after(Iterator pos, const T& value)
{
return Iterator(nullptr, nullptr, nullptr);
}
/**
* Add a new element to the front of our list.
*/
void push_front(const T& value)
{
}
/**
* Add an element to the end of this list.
*
* Should return an iterator pointing to the newly created node.
*/
Iterator push_back(const T& value)
{
Node<T> *new_node = new Node<T>(value, nullptr, tail_);
if (tail_ == nullptr) {
head_ = new_node;
} else {
tail_->setNext(new_node);
}
tail_ = new_node;
++size_;
return Iterator(new_node, head_, tail_);
}
/**
* Remove the node at the front of our list
*
* Should throw an exception if our list is empty
*/
void pop_front()
{
}

Recommended

How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfcallawaycorb73779
 
How do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfHow do I fix it in LinkedList.javaLinkedList.java Define.pdf
How do I fix it in LinkedList.javaLinkedList.java Define.pdfmail931892
 
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdf
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdfAdrianEBJKingr
 
How do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdfHow do I fix it in javaLinkedList.java Defines a doubl.pdf
How do I fix it in javaLinkedList.java Defines a doubl.pdffmac5
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdfBANSALANKIT1077
 
How do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfHow do I fix it in LinkedList.javathis is what i didLabProgra.pdf
How do I fix it in LinkedList.javathis is what i didLabProgra.pdfmail931892
 

More Related Content

Similar to C++ pleae Your welcome DoublyLinkedList thisgthea.pdf

import java.util.NoSuchElementException;public class LinkedListT.pdf
import java.util.NoSuchElementException;public class LinkedListT.pdfimport java.util.NoSuchElementException;public class LinkedListT.pdf
import java.util.NoSuchElementException;public class LinkedListT.pdfarkmuzikllc
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxmckellarhastings
 
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docx
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docxI'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docx
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docxJacobUasThomsoni
 
template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdfashokadyes
 
In C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdfIn C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdffantoosh1
 
for initializer_list include ltinitializer_listgt .pdf
 for initializer_list include ltinitializer_listgt .pdf for initializer_list include ltinitializer_listgt .pdf
for initializer_list include ltinitializer_listgt .pdfajay1317
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfmalavshah9013
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfnaslin841216
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfmail931892
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdfConint29
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxcgraciela1
 

Similar to C++ pleae Your welcome DoublyLinkedList thisgthea.pdf (20)

import java.util.NoSuchElementException;public class LinkedListT.pdf
import java.util.NoSuchElementException;public class LinkedListT.pdfimport java.util.NoSuchElementException;public class LinkedListT.pdf
import java.util.NoSuchElementException;public class LinkedListT.pdf
 
For this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docxFor this micro assignment, you must implement two Linked List functi.docx
For this micro assignment, you must implement two Linked List functi.docx
 
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docx
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docxI'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docx
I'm having trouble with PostfixTester-java and PostfixEvaluator-java- (1).docx
 
template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdf
 
In C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdfIn C++Add the function min as an abstract function to the classar.pdf
In C++Add the function min as an abstract function to the classar.pdf
 
for initializer_list include ltinitializer_listgt .pdf
 for initializer_list include ltinitializer_listgt .pdf for initializer_list include ltinitializer_listgt .pdf
for initializer_list include ltinitializer_listgt .pdf
 
The LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdfThe LinkedList1 class implements a Linked list. class.pdf
The LinkedList1 class implements a Linked list. class.pdf
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
 
Please complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docxPlease complete all the code as per instructions in Java programming.docx
Please complete all the code as per instructions in Java programming.docx
 

More from jaipur2

Business organizations are relying more and more on social m.pdf
Business organizations are relying more and more on social m.pdfBusiness organizations are relying more and more on social m.pdf
Business organizations are relying more and more on social m.pdfjaipur2
 
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfjaipur2
 
Budget Analysis A budget is an expression of managements e.pdf
Budget Analysis A budget is an expression of managements e.pdfBudget Analysis A budget is an expression of managements e.pdf
Budget Analysis A budget is an expression of managements e.pdfjaipur2
 
BUSINESS LAW QUESTION Question 2 Ashik owns a landed pr.pdf
BUSINESS LAW QUESTION Question 2     Ashik owns a landed pr.pdfBUSINESS LAW QUESTION Question 2     Ashik owns a landed pr.pdf
BUSINESS LAW QUESTION Question 2 Ashik owns a landed pr.pdfjaipur2
 
Bu altrma Boston konut veri setini ierir a Balamak iin.pdf
Bu altrma Boston konut veri setini ierir a Balamak iin.pdfBu altrma Boston konut veri setini ierir a Balamak iin.pdf
Bu altrma Boston konut veri setini ierir a Balamak iin.pdfjaipur2
 
Bu snf arkadamn yazd bir tartma gnderisidir Yant vermem.pdf
Bu snf arkadamn yazd bir tartma gnderisidir  Yant vermem.pdfBu snf arkadamn yazd bir tartma gnderisidir  Yant vermem.pdf
Bu snf arkadamn yazd bir tartma gnderisidir Yant vermem.pdfjaipur2
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdfjaipur2
 
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdf
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdfBu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdf
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdfjaipur2
 
C++ ONLY Write a program that will keep track of information.pdf
C++ ONLY Write a program that will keep track of information.pdfC++ ONLY Write a program that will keep track of information.pdf
C++ ONLY Write a program that will keep track of information.pdfjaipur2
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdfjaipur2
 
c++ please Write a recursive function that takes a string pa.pdf
c++ please Write a recursive function that takes a string pa.pdfc++ please Write a recursive function that takes a string pa.pdf
c++ please Write a recursive function that takes a string pa.pdfjaipur2
 
C The following payoff for three mutually exclusive projec.pdf
C The following payoff for three mutually exclusive projec.pdfC The following payoff for three mutually exclusive projec.pdf
C The following payoff for three mutually exclusive projec.pdfjaipur2
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfjaipur2
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfjaipur2
 
C++ Define a function unbalanced brackets that takes in a st.pdf
C++ Define a function unbalanced brackets that takes in a st.pdfC++ Define a function unbalanced brackets that takes in a st.pdf
C++ Define a function unbalanced brackets that takes in a st.pdfjaipur2
 
C++ The following code fragment will no compile What is w.pdf
C++   The following code fragment will no compile What is w.pdfC++   The following code fragment will no compile What is w.pdf
C++ The following code fragment will no compile What is w.pdfjaipur2
 
c What saving rate is needed to yield the goldenrule capi.pdf
c What saving rate is needed to yield the goldenrule capi.pdfc What saving rate is needed to yield the goldenrule capi.pdf
c What saving rate is needed to yield the goldenrule capi.pdfjaipur2
 
c++ Write the implementations of two functions to carry o.pdf
c++    Write the implementations of two functions to carry o.pdfc++    Write the implementations of two functions to carry o.pdf
c++ Write the implementations of two functions to carry o.pdfjaipur2
 
C++ Write a program that will keep track of information ab.pdf
C++   Write a program that will keep track of information ab.pdfC++   Write a program that will keep track of information ab.pdf
C++ Write a program that will keep track of information ab.pdfjaipur2
 

More from jaipur2 (20)

Business organizations are relying more and more on social m.pdf
Business organizations are relying more and more on social m.pdfBusiness organizations are relying more and more on social m.pdf
Business organizations are relying more and more on social m.pdf
 
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
 
Budget Analysis A budget is an expression of managements e.pdf
Budget Analysis A budget is an expression of managements e.pdfBudget Analysis A budget is an expression of managements e.pdf
Budget Analysis A budget is an expression of managements e.pdf
 
BUSINESS LAW QUESTION Question 2 Ashik owns a landed pr.pdf
BUSINESS LAW QUESTION Question 2     Ashik owns a landed pr.pdfBUSINESS LAW QUESTION Question 2     Ashik owns a landed pr.pdf
BUSINESS LAW QUESTION Question 2 Ashik owns a landed pr.pdf
 
Bu altrma Boston konut veri setini ierir a Balamak iin.pdf
Bu altrma Boston konut veri setini ierir a Balamak iin.pdfBu altrma Boston konut veri setini ierir a Balamak iin.pdf
Bu altrma Boston konut veri setini ierir a Balamak iin.pdf
 
Bu snf arkadamn yazd bir tartma gnderisidir Yant vermem.pdf
Bu snf arkadamn yazd bir tartma gnderisidir  Yant vermem.pdfBu snf arkadamn yazd bir tartma gnderisidir  Yant vermem.pdf
Bu snf arkadamn yazd bir tartma gnderisidir Yant vermem.pdf
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
 
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdf
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdfBu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdf
Bu ifadelerin her birinin doru mu yoksa yanl m olduuna karar.pdf
 
C++ ONLY Write a program that will keep track of information.pdf
C++ ONLY Write a program that will keep track of information.pdfC++ ONLY Write a program that will keep track of information.pdf
C++ ONLY Write a program that will keep track of information.pdf
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdf
 
c++ please Write a recursive function that takes a string pa.pdf
c++ please Write a recursive function that takes a string pa.pdfc++ please Write a recursive function that takes a string pa.pdf
c++ please Write a recursive function that takes a string pa.pdf
 
C The following payoff for three mutually exclusive projec.pdf
C The following payoff for three mutually exclusive projec.pdfC The following payoff for three mutually exclusive projec.pdf
C The following payoff for three mutually exclusive projec.pdf
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdf
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdf
 
C++ Define a function unbalanced brackets that takes in a st.pdf
C++ Define a function unbalanced brackets that takes in a st.pdfC++ Define a function unbalanced brackets that takes in a st.pdf
C++ Define a function unbalanced brackets that takes in a st.pdf
 
C++ The following code fragment will no compile What is w.pdf
C++   The following code fragment will no compile What is w.pdfC++   The following code fragment will no compile What is w.pdf
C++ The following code fragment will no compile What is w.pdf
 
c What saving rate is needed to yield the goldenrule capi.pdf
c What saving rate is needed to yield the goldenrule capi.pdfc What saving rate is needed to yield the goldenrule capi.pdf
c What saving rate is needed to yield the goldenrule capi.pdf
 
c++ Write the implementations of two functions to carry o.pdf
c++    Write the implementations of two functions to carry o.pdfc++    Write the implementations of two functions to carry o.pdf
c++ Write the implementations of two functions to carry o.pdf
 
C++ Write a program that will keep track of information ab.pdf
C++   Write a program that will keep track of information ab.pdfC++   Write a program that will keep track of information ab.pdf
C++ Write a program that will keep track of information ab.pdf
 

Recently uploaded

Successful projects and failed programmes – the cost of not designing the who...
Successful projects and failed programmes – the cost of not designing the who...Successful projects and failed programmes – the cost of not designing the who...
Successful projects and failed programmes – the cost of not designing the who...Association for Project Management
 
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfA Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfOH TEIK BIN
 
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...liera silvan
 
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdf
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdfSSC Hindu Religion and Moral Education MCQ Solutions 2024.pdf
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdfMohonDas
 
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.Florence Dayana
 
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...EduSkills OECD
 
Database Security Methods, DAC, MAC,View
Database Security Methods, DAC, MAC,ViewDatabase Security Methods, DAC, MAC,View
Database Security Methods, DAC, MAC,ViewDr-Dipali Meher
 
Peninsula Channel Commanders Rules Handbook
Peninsula Channel Commanders Rules HandbookPeninsula Channel Commanders Rules Handbook
Peninsula Channel Commanders Rules Handbookpccwebmasterhmb
 
2024-02-24_Session 1 - PMLE_UPDATED.pptx
2024-02-24_Session 1 - PMLE_UPDATED.pptx2024-02-24_Session 1 - PMLE_UPDATED.pptx
2024-02-24_Session 1 - PMLE_UPDATED.pptxgdgsurrey
 
Discussing the new Competence Framework for project managers in the built env...
Discussing the new Competence Framework for project managers in the built env...Discussing the new Competence Framework for project managers in the built env...
Discussing the new Competence Framework for project managers in the built env...Association for Project Management
 
Plagiarism, Types & Consequences by Dr. Sarita Anand
Plagiarism, Types & Consequences by Dr. Sarita AnandPlagiarism, Types & Consequences by Dr. Sarita Anand
Plagiarism, Types & Consequences by Dr. Sarita AnandDr. Sarita Anand
 
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Katherine Villaluna
 
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...SUMIT TIWARI
 
Add Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesAdd Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesCeline George
 
Mycology Update February 2024 Microbes with Morgan
Mycology Update February 2024 Microbes with MorganMycology Update February 2024 Microbes with Morgan
Mycology Update February 2024 Microbes with MorganMargie Morgan
 
Unit 5th topic Drugs used in congestive Heart failure and shock.pdf
Unit 5th topic Drugs used in congestive Heart failure and shock.pdfUnit 5th topic Drugs used in congestive Heart failure and shock.pdf
Unit 5th topic Drugs used in congestive Heart failure and shock.pdfSUMIT TIWARI
 
Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)CaraSkikne1
 
Kartik Nair In Media Res Media Component
Kartik Nair In Media Res Media ComponentKartik Nair In Media Res Media Component
Kartik Nair In Media Res Media ComponentInMediaRes1
 
2.27.24 Malcolm X and the Black Freedom Struggle.pptx
2.27.24 Malcolm X and the Black Freedom Struggle.pptx2.27.24 Malcolm X and the Black Freedom Struggle.pptx
2.27.24 Malcolm X and the Black Freedom Struggle.pptxMaryPotorti1
 

Recently uploaded (20)

Successful projects and failed programmes – the cost of not designing the who...
Successful projects and failed programmes – the cost of not designing the who...Successful projects and failed programmes – the cost of not designing the who...
Successful projects and failed programmes – the cost of not designing the who...
 
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdfA Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
A Free eBook ~ Mental Exercise ...Puzzles to Analyze.pdf
 
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...
EmpTech Lesson 7 - Online Creation Tools, Platforms, and Applications for ICT...
 
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdf
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdfSSC Hindu Religion and Moral Education MCQ Solutions 2024.pdf
SSC Hindu Religion and Moral Education MCQ Solutions 2024.pdf
 
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdfDr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
Dr.M.Florence Dayana-Cloud Computing-unit - 4.pdf
 
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...
Managing Choice, Coherence and Specialisation in Upper Secondary Education - ...
 
Database Security Methods, DAC, MAC,View
Database Security Methods, DAC, MAC,ViewDatabase Security Methods, DAC, MAC,View
Database Security Methods, DAC, MAC,View
 
Peninsula Channel Commanders Rules Handbook
Peninsula Channel Commanders Rules HandbookPeninsula Channel Commanders Rules Handbook
Peninsula Channel Commanders Rules Handbook
 
2024-02-24_Session 1 - PMLE_UPDATED.pptx
2024-02-24_Session 1 - PMLE_UPDATED.pptx2024-02-24_Session 1 - PMLE_UPDATED.pptx
2024-02-24_Session 1 - PMLE_UPDATED.pptx
 
Discussing the new Competence Framework for project managers in the built env...
Discussing the new Competence Framework for project managers in the built env...Discussing the new Competence Framework for project managers in the built env...
Discussing the new Competence Framework for project managers in the built env...
 
Plagiarism, Types & Consequences by Dr. Sarita Anand
Plagiarism, Types & Consequences by Dr. Sarita AnandPlagiarism, Types & Consequences by Dr. Sarita Anand
Plagiarism, Types & Consequences by Dr. Sarita Anand
 
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
Practical Research 1, Lesson 5: DESIGNING A RESEARCH PROJECT RELATED TO DAILY...
 
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...
Bilingual notes of Pharmacognosy chapter 4Glycosides, Volatile oils,Tannins,R...
 
Add Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 SalesAdd Products From Catalog in Odoo 17 Sales
Add Products From Catalog in Odoo 17 Sales
 
Mycology Update February 2024 Microbes with Morgan
Mycology Update February 2024 Microbes with MorganMycology Update February 2024 Microbes with Morgan
Mycology Update February 2024 Microbes with Morgan
 
Unit 5th topic Drugs used in congestive Heart failure and shock.pdf
Unit 5th topic Drugs used in congestive Heart failure and shock.pdfUnit 5th topic Drugs used in congestive Heart failure and shock.pdf
Unit 5th topic Drugs used in congestive Heart failure and shock.pdf
 
Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)Understanding Canada's international higher education landscape (2024)
Understanding Canada's international higher education landscape (2024)
 
Kartik Nair In Media Res Media Component
Kartik Nair In Media Res Media ComponentKartik Nair In Media Res Media Component
Kartik Nair In Media Res Media Component
 
2.27.24 Malcolm X and the Black Freedom Struggle.pptx
2.27.24 Malcolm X and the Black Freedom Struggle.pptx2.27.24 Malcolm X and the Black Freedom Struggle.pptx
2.27.24 Malcolm X and the Black Freedom Struggle.pptx
 
Advance Mobile Application Development class 04
Advance Mobile Application Development class 04Advance Mobile Application Development class 04
Advance Mobile Application Development class 04
 

C++ pleae Your welcome DoublyLinkedList thisgthea.pdf

  • 1. C++ pleae /// Your welcome DoublyLinkedList() { this->head_ = nullptr; this->tail_ = nullptr; this->size_ = 0; } /// Copy Constructor DoublyLinkedList(DoublyLinkedList& other) { for (auto it = other.begin(); it!= other.end(); ++it) { this->push_back(*it); } } /// DTOR: Your welcome ~DoublyLinkedList() { this->clear(); } /** * Clear the list and assign the same value, count times. * If count was 5, T was int, and value was 3, * we'd end up with a list like {3, 3, 3, 3, 3} */ void assign(size_t count, const T& value) { this->clear(); for (size_t i = 0; i < count; ++i) { this->push_back(value); } } /** * Clear the list and assign values from another list. * The 'first' iterator points to the first item copied from the other list. * The 'last' iterator points to the last item copied from the other list. * * Example: * Suppose we have a source list like {8, 4, 3, 2, 7, 1} * Suppose first points to the 4 * Suppose last points to the 7 * We should end up with our list becoming: {4, 3, 2, 7}
  • 2. * * If the user code sends out-of-order iterators, * just copy from 'first' to the end of the source list * Example: first=7, last=4 from the list above would give us: * {7, 1} */ void assign(Iterator first, Iterator last) { this->clear(); Iterator it; for (it = first; it!= last; ++it) { this->push_back(*it); } if (it != nullptr && it->next == last) { this->push_back(*last); } } /// Return a pointer to the head node, if any Node<T>* head() { return head_; } /// Return a pointer to the tail node, if any Node<T>* tail() { return tail_; } /** * Return an iterator that points to the head of our list */ Iterator begin() { return Iterator(this->head_); } /** * Return an iterator that points to the last element (tail) of our list */ Iterator last() { return Iterator(this->tail_); } /** * Should return an iterator that represents being past the end of our nodes, * or just that we are finished. * You can make this a nullptr or use some other scheme of your choosing, * as long as it works with the logic of the rest of your implementations. */ Iterator end()
  • 3. { return Iterator(nullptr); } /** * Returns true if our list is empty */ bool empty() const { return this->size_ == 0; } /** * Returns the current size of the list * Should finish in constant time! * (keep track of the size elsewhere) */ size_t size() const { return 0; } /** * Clears our entire list, making it empty * Remember: All removal operations should be memory-leak free. */ void clear() { size_ = 0; Node<T> *node = this->head_; while (node!= nullptr) { Node<T> *next = node->next_; delete node; node = next; } this->head_ = nullptr; this->tail_ = nullptr; } /** * Insert an element after the node pointed to by the pos Iterator * * If the list is currently empty, * ignore the iterator and just make the new node at the head/tail (list of length 1). * * If the incoming iterator is this->end(), insert the element at the tail
  • 4. * * Should return an iterator that points to the newly added node * * To avoid repeated code, it might be a good idea to have other methods * rely on this one. */ Iterator insert_after(Iterator pos, const T& value) { return Iterator(nullptr, nullptr, nullptr); } /** * Insert a new element after the index pos. * Should work with an empty list. * * Should return an iterator pointing to the newly created node * * To reduce repeated code, you may want to simply find * an iterator to the node at the pos index, then * send it to the other overload of this method. */ Iterator insert_after(size_t pos, const T& value) { return Iterator(nullptr, nullptr, nullptr); } /** * Erase the node pointed to by the Iterator's cursor. * * If the 'pos' iterator does not point to a valid node, * throw an std::range_error * * Return an iterator to the node AFTER the one we erased, * or this->end() if we just erased the tail */ Iterator erase(Iterator pos) { return Iterator(nullptr, nullptr, nullptr); } /** * Add an element just after the one pointed to by the 'pos' iterator * * Should return an iterator pointing to the newly created node */
  • 5. Iterator push_after(Iterator pos, const T& value) { return Iterator(nullptr, nullptr, nullptr); } /** * Add a new element to the front of our list. */ void push_front(const T& value) { } /** * Add an element to the end of this list. * * Should return an iterator pointing to the newly created node. */ Iterator push_back(const T& value) { Node<T> *new_node = new Node<T>(value, nullptr, tail_); if (tail_ == nullptr) { head_ = new_node; } else { tail_->setNext(new_node); } tail_ = new_node; ++size_; return Iterator(new_node, head_, tail_); } /** * Remove the node at the front of our list * * Should throw an exception if our list is empty */ void pop_front() { }