SlideShare a Scribd company logo
1 of 4
Download to read offline
Please fix my errors
class Iterator
{
public:
/// Constructor taking a head and tail pointer; YOU'RE WELCOME
Iterator(Node<T> *head, Node<T> *tail) : head_(head), tail_(tail)
{
cursor_ = end();
}
/// Constructor taking a head, tail, and cursor pointer; YOU'RE WELCOME
Iterator(Node<T> *head, Node<T> *tail, Node<T> *cursor) : head_(head), tail_(tail),
cursor_(cursor) {}
/// Get a pointer to the head node, or end() if this list is empty
Node<T> *begin() { return head_; }
/// Get a node pointer representing "end" (aka "depleted"). Probably want to just use nullptr.
Node<T> *end() { return nullptr; }
/// Get the node to which this iterator is currently pointing
Node<T> *getCursor() { return cursor_; }
/**
* Assignment operator
* Return a copy of this Iterator, after modification
*/
Iterator &operator=(const Iterator &other)
{
head_ = other.head_;
tail_ = other.tail_;
cursor_ = other.cursor_;
return *this;
}
/**
* Comparison operator
* Returns true if this iterator is equal to the other iterator, false otherwise
*/
bool operator==(const Iterator &other)
{
return cursor_ == other.cursor_;
}
/**
* Inequality comparison operator
* Returns true if this iterator is not equal to the other iterator, false otherwise
*/
bool operator!=(const Iterator &other)
{
return !(*this == other);
}
/**
* Prefix increment operator
* Return a copy of this Iterator, after modification
*/
Iterator &operator++()
{
cursor_ = cursor_->getNext();
return *this;
}
/*** Postfix increment
* Return a copy of this Iterator, BEFORE it was modified
*/
Iterator operator++(int)
{
Iterator copy(*this);
++(*this);
return copy;
}
/*** Prefix decrement operator
* Return a copy of this Iterator, after modification
*/
Iterator &operator--()
{
cursor_ = cursor_->getPrev();
return *this;
}
/**
* Postfix decrement operator
* Return a copy of this Iterator BEFORE it was modified
*/
Iterator operator--(int)
{
Iterator copy = *this;
--(*this);
return copy;
}
/**
* AdditionAssignment operator
* Return a copy of the current iterator, after modification
*/
Iterator operator+=(size_t add)
{
for (size_t i = 0; i < add && cursor_ != nullptr; ++i)
{
cursor_ = cursor_->getNext();
}
return *this;
}
/**
* SubtractionAssignment operator
* Return a copy of the current iterator, after modification
*/
Iterator operator-=(size_t sub)
{
for (size_t i = 0; i < sub && cursor_ != nullptr; ++i)
{
cursor_ = cursor_->getPrev();
}
return *this;
}
/**
* AdditionAssignment operator, supporting positive or negative ints
*/
Iterator operator+=(int add)
{
if (add > 0)
{
for (int i = 0; i < add && cursor_ != nullptr; ++i)
{
cursor_ = cursor_->getNext();
}
}
else
{
for (int i = 0; i > add && cursor_->getPrev() != nullptr; --i)
{
cursor_ = cursor_->getPrev();
}
}
return *this;
}
/**
* SubtractionAssignment operator, supporting positive or negative ints
*/
Iterator operator-=(int subtract)
{
// This function adds an integer to the current iterators position in the list,
if (subtract > 0)
{
for (int i = 0; i < subtract && cursor_->getPrev() != nullptr; ++i)
{
cursor_ = cursor_->getPrev();
}
}
else
{
for (int i = 0; i > subtract && cursor_ != nullptr; --i)
{
cursor_ = cursor_->getPrev();
}
}
return *this;
}
/**
* Dereference operator returns a reference to the ELEMENT contained with the current node
*/
T &operator*()
{
return *cursor_->getElement();
}
private:
/// Pointer to the head node
Node<T> *head_ = nullptr;
/// Pointer to the tail node
Node<T> *tail_ = nullptr;
Node<T> *cursor_ = nullptr;
friend class DoublyLinkedList;
};

More Related Content

Similar to Please fix my errors class Iterator public Construc.pdf

1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
 
Please correct my errors upvote Clears our entire .pdf
Please correct my errors upvote      Clears our entire .pdfPlease correct my errors upvote      Clears our entire .pdf
Please correct my errors upvote Clears our entire .pdfkitty811
 
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdfpetercoiffeur18
 
Help in JAVAThis program should input numerator and denominator f.pdf
Help in JAVAThis program should input numerator and denominator f.pdfHelp in JAVAThis program should input numerator and denominator f.pdf
Help in JAVAThis program should input numerator and denominator f.pdfmanjan6
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfcontact32
 
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docxAvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docxrock73
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfsales98
 
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
 
how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
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
 
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
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfaggarwalopticalsco
 
Learn c++ (functions) with nauman ur rehman
Learn  c++ (functions) with nauman ur rehmanLearn  c++ (functions) with nauman ur rehman
Learn c++ (functions) with nauman ur rehmanNauman Rehman
 
Use a simple vector you created before to create two other more
Use a simple vector you created before to create two other more Use a simple vector you created before to create two other more
Use a simple vector you created before to create two other more steviesellars
 
The following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdfThe following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdf4babies2010
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdffantasiatheoutofthef
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxjoellemurphey
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdfankit11134
 

Similar to Please fix my errors class Iterator public Construc.pdf (20)

1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
Please correct my errors upvote Clears our entire .pdf
Please correct my errors upvote      Clears our entire .pdfPlease correct my errors upvote      Clears our entire .pdf
Please correct my errors upvote Clears our entire .pdf
 
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
 
Help in JAVAThis program should input numerator and denominator f.pdf
Help in JAVAThis program should input numerator and denominator f.pdfHelp in JAVAThis program should input numerator and denominator f.pdf
Help in JAVAThis program should input numerator and denominator f.pdf
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdf
 
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docxAvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
AvlTree.h#ifndef AVL_TREE_H#define AVL_TREE_H#include d.docx
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
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
 
how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
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.pdf
 
Ch7 C++
Ch7 C++Ch7 C++
Ch7 C++
 
Link list
Link listLink list
Link list
 
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
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
 
Learn c++ (functions) with nauman ur rehman
Learn  c++ (functions) with nauman ur rehmanLearn  c++ (functions) with nauman ur rehman
Learn c++ (functions) with nauman ur rehman
 
Use a simple vector you created before to create two other more
Use a simple vector you created before to create two other more Use a simple vector you created before to create two other more
Use a simple vector you created before to create two other more
 
The following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdfThe following is the (incomplete) header file for the class Fracti.pdf
The following is the (incomplete) header file for the class Fracti.pdf
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
 

More from kitty811

please fix this code so that the tests pass css Selec.pdf
please fix this code so that the tests pass        css Selec.pdfplease fix this code so that the tests pass        css Selec.pdf
please fix this code so that the tests pass css Selec.pdfkitty811
 
please help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfplease help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfkitty811
 
please fill in the blanks below the proc structure .pdf
please fill in the blanks below    the proc structure  .pdfplease fill in the blanks below    the proc structure  .pdf
please fill in the blanks below the proc structure .pdfkitty811
 
Please explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfPlease explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfkitty811
 
Please help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfPlease help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfkitty811
 
Please help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfPlease help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfkitty811
 
Please graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfPlease graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfkitty811
 
please help Let X and Y be random variables with joint dens.pdf
please help  Let X and Y be random variables with joint dens.pdfplease help  Let X and Y be random variables with joint dens.pdf
please help Let X and Y be random variables with joint dens.pdfkitty811
 
Please go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfPlease go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfkitty811
 
Please give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfPlease give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfkitty811
 
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfplease give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfkitty811
 
please full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfplease full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfkitty811
 
Please find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfPlease find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfkitty811
 
Please fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfPlease fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfkitty811
 
please fast answer Suppose that XU nif 01 You draw a sa.pdf
please fast answer  Suppose that XU nif 01 You draw a sa.pdfplease fast answer  Suppose that XU nif 01 You draw a sa.pdf
please fast answer Suppose that XU nif 01 You draw a sa.pdfkitty811
 
Please explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfPlease explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfkitty811
 
Please explain why c is correct Why does this return and e.pdf
Please explain why c is correct  Why does this return and e.pdfPlease explain why c is correct  Why does this return and e.pdf
Please explain why c is correct Why does this return and e.pdfkitty811
 
Please code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfPlease code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfkitty811
 
Please explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfPlease explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfkitty811
 
Please explain how to find the answer Thank you You may ne.pdf
Please explain how to find the answer Thank you You may ne.pdfPlease explain how to find the answer Thank you You may ne.pdf
Please explain how to find the answer Thank you You may ne.pdfkitty811
 

More from kitty811 (20)

please fix this code so that the tests pass css Selec.pdf
please fix this code so that the tests pass        css Selec.pdfplease fix this code so that the tests pass        css Selec.pdf
please fix this code so that the tests pass css Selec.pdf
 
please help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdfplease help Below are the ages at which US presidents bega.pdf
please help Below are the ages at which US presidents bega.pdf
 
please fill in the blanks below the proc structure .pdf
please fill in the blanks below    the proc structure  .pdfplease fill in the blanks below    the proc structure  .pdf
please fill in the blanks below the proc structure .pdf
 
Please explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdfPlease explain these steps Not sure how to go from first li.pdf
Please explain these steps Not sure how to go from first li.pdf
 
Please help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdfPlease help Edgar Given the following API for a mutable Em.pdf
Please help Edgar Given the following API for a mutable Em.pdf
 
Please help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdfPlease help 1 Use any data structures or control flows as a.pdf
Please help 1 Use any data structures or control flows as a.pdf
 
Please graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdfPlease graph the spectrum using only MATLAB and provide the .pdf
Please graph the spectrum using only MATLAB and provide the .pdf
 
please help Let X and Y be random variables with joint dens.pdf
please help  Let X and Y be random variables with joint dens.pdfplease help  Let X and Y be random variables with joint dens.pdf
please help Let X and Y be random variables with joint dens.pdf
 
Please go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdfPlease go through the Review Article and submit a summary of.pdf
Please go through the Review Article and submit a summary of.pdf
 
Please give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdfPlease give me a new topic not the one already on cheggQU.pdf
Please give me a new topic not the one already on cheggQU.pdf
 
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdfplease give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
please give ANY inswer in 30 min The CONTROL pyloric rhythm .pdf
 
please full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdfplease full it please full it 2 Genie and Dan have just ha.pdf
please full it please full it 2 Genie and Dan have just ha.pdf
 
Please find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdfPlease find the Below YAML code whihc is meant to achieve th.pdf
Please find the Below YAML code whihc is meant to achieve th.pdf
 
Please fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdfPlease fill in the blanks of the 5 questions Required inform.pdf
Please fill in the blanks of the 5 questions Required inform.pdf
 
please fast answer Suppose that XU nif 01 You draw a sa.pdf
please fast answer  Suppose that XU nif 01 You draw a sa.pdfplease fast answer  Suppose that XU nif 01 You draw a sa.pdf
please fast answer Suppose that XU nif 01 You draw a sa.pdf
 
Please explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdfPlease explain in steps so I may be able to follow and learn.pdf
Please explain in steps so I may be able to follow and learn.pdf
 
Please explain why c is correct Why does this return and e.pdf
Please explain why c is correct  Why does this return and e.pdfPlease explain why c is correct  Why does this return and e.pdf
Please explain why c is correct Why does this return and e.pdf
 
Please code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdfPlease code in C in Visual Studio Thank you 1 Create a C.pdf
Please code in C in Visual Studio Thank you 1 Create a C.pdf
 
Please explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdfPlease explain step by step Current Attempt in Progress As .pdf
Please explain step by step Current Attempt in Progress As .pdf
 
Please explain how to find the answer Thank you You may ne.pdf
Please explain how to find the answer Thank you You may ne.pdfPlease explain how to find the answer Thank you You may ne.pdf
Please explain how to find the answer Thank you You may ne.pdf
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
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
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
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
 

Please fix my errors class Iterator public Construc.pdf

  • 1. Please fix my errors class Iterator { public: /// Constructor taking a head and tail pointer; YOU'RE WELCOME Iterator(Node<T> *head, Node<T> *tail) : head_(head), tail_(tail) { cursor_ = end(); } /// Constructor taking a head, tail, and cursor pointer; YOU'RE WELCOME Iterator(Node<T> *head, Node<T> *tail, Node<T> *cursor) : head_(head), tail_(tail), cursor_(cursor) {} /// Get a pointer to the head node, or end() if this list is empty Node<T> *begin() { return head_; } /// Get a node pointer representing "end" (aka "depleted"). Probably want to just use nullptr. Node<T> *end() { return nullptr; } /// Get the node to which this iterator is currently pointing Node<T> *getCursor() { return cursor_; } /** * Assignment operator * Return a copy of this Iterator, after modification */ Iterator &operator=(const Iterator &other) { head_ = other.head_; tail_ = other.tail_; cursor_ = other.cursor_; return *this; } /** * Comparison operator * Returns true if this iterator is equal to the other iterator, false otherwise */ bool operator==(const Iterator &other) { return cursor_ == other.cursor_; } /** * Inequality comparison operator * Returns true if this iterator is not equal to the other iterator, false otherwise */
  • 2. bool operator!=(const Iterator &other) { return !(*this == other); } /** * Prefix increment operator * Return a copy of this Iterator, after modification */ Iterator &operator++() { cursor_ = cursor_->getNext(); return *this; } /*** Postfix increment * Return a copy of this Iterator, BEFORE it was modified */ Iterator operator++(int) { Iterator copy(*this); ++(*this); return copy; } /*** Prefix decrement operator * Return a copy of this Iterator, after modification */ Iterator &operator--() { cursor_ = cursor_->getPrev(); return *this; } /** * Postfix decrement operator * Return a copy of this Iterator BEFORE it was modified */ Iterator operator--(int) { Iterator copy = *this; --(*this); return copy; } /** * AdditionAssignment operator
  • 3. * Return a copy of the current iterator, after modification */ Iterator operator+=(size_t add) { for (size_t i = 0; i < add && cursor_ != nullptr; ++i) { cursor_ = cursor_->getNext(); } return *this; } /** * SubtractionAssignment operator * Return a copy of the current iterator, after modification */ Iterator operator-=(size_t sub) { for (size_t i = 0; i < sub && cursor_ != nullptr; ++i) { cursor_ = cursor_->getPrev(); } return *this; } /** * AdditionAssignment operator, supporting positive or negative ints */ Iterator operator+=(int add) { if (add > 0) { for (int i = 0; i < add && cursor_ != nullptr; ++i) { cursor_ = cursor_->getNext(); } } else { for (int i = 0; i > add && cursor_->getPrev() != nullptr; --i) { cursor_ = cursor_->getPrev(); } } return *this;
  • 4. } /** * SubtractionAssignment operator, supporting positive or negative ints */ Iterator operator-=(int subtract) { // This function adds an integer to the current iterators position in the list, if (subtract > 0) { for (int i = 0; i < subtract && cursor_->getPrev() != nullptr; ++i) { cursor_ = cursor_->getPrev(); } } else { for (int i = 0; i > subtract && cursor_ != nullptr; --i) { cursor_ = cursor_->getPrev(); } } return *this; } /** * Dereference operator returns a reference to the ELEMENT contained with the current node */ T &operator*() { return *cursor_->getElement(); } private: /// Pointer to the head node Node<T> *head_ = nullptr; /// Pointer to the tail node Node<T> *tail_ = nullptr; Node<T> *cursor_ = nullptr; friend class DoublyLinkedList; };