Advances The Iterator To The Next Node example essay topic
668 words
#include #include #include using name space std; class List; class Iterator; class Node{public: / Constructs a node with a given data value. @param's the data to store in this node / Node (string s); private: string data; Node previous; Node next; friend class List; friend class Iterator; }; class List{public: / Constructs an empty list; /List ; / Appends an element to the list. @param's the value to append / void push back (string s); / Inserts an element into the list. @param it er the position before which to insert@param's the value to append / void insert (Iterator it er, string s); / Removes an element from the list. @param i the position to remove@return an iterator pointing to the element after the erased element / Iterator erase (Iterator i); / Gets the beginning position of the list. @return an iterator pointing to the beginning of the list / Iterator begin ; / Gets the past-the-end position of the list. @return an iterator pointing past the end of the list / Iterator end ; void reverse ; private: Node first; Node last; }; class Iterator{public: / Constructs an iterator that does not point into any list. /Iterator ; / Looks up the value at a position. @return the value of the node to which the iterator points / string get cost; / Advances the iterator to the next node. /void next ; / Moves the iterator to the previous node. /void previous ; / Compares two iterators@param b the iterator to compare with this iterator@return true if this iterator and b are equal / book equals (Iterator b) cost; private: Node position; Node last; friend class List; }; Node: : Node (string s) { data ='s; previous = NULL; next = NULL; }List: : List { first = NULL; last = NULL; }void List: : push back (string s) { Node new node = new Node (s); if (last = = NULL) / list is empty /{ first = new node; last = new node; }else{ new node- previous = last; last- next = new node; last = new node; }}void List: : insert (Iterator it er, string s) { if (it er. position = = NULL) { push back (s); return; }Node after = it er. position; Node before = after- previous; Node new node = new Node (s); new node- previous = before; new node- next = after; after- previous = new node; if (before = = NULL) / insert at beginning / first = new node; else before- next = new node; }Iterator List: : erase (Iterator i) { Iterator it er = i; assert (it er. position! = NULL); Node remove = it er. position; Node before = remove- previous; Node after = remove- next; if (remove = = first) first = after; else before- next = after; if (remove = = last) last = before; else after- previous = before; it er. position = after; delete remove; return it er; }void List: : reverse {}Iterator List: : begin { Iterator it er; it er. position = first; it er. last = last; return it er; }Iterator List: : end { Iterator it er; it er. position = NULL; it er. last = last; return it er; }Iterator: : Iterator { position = NULL; last = NULL; }string Iterator: : get cost{ assert (position! = NULL); return position- data; }void Iterator: : next { assert (position! = NULL); position = position- next; }void Iterator: : previous { if (position = = NULL) position = last; else position = position- previous; assert (position! = NULL); }book Iterator: : equals (Iterator b) cost{ return position = = b. position; }int main { List staff; staff. push back ('Cracker, Carl'); staff. push back ('Hacker, Harry'); staff. push back ('Lam, Larry'); staff. push back ('Sandman, Susan'); staff. reverse ; / print all values / for (Iterator pos = staff. begin ; ! pos. equals (staff. end ); pos. next ) c out.
Things every student should keep in mind
- Free example essays found anywhere online are available to anyone, which makes them used, re-used, paraphrased, and abused millions of times.
- Watch out, some are poorly written!
- We strongly discourage you to submit free essays or any of their parts for credit at your school -- they are easily detected by PLAGIARISM CHECKERS.
- Get a brand-new, 100% original paper that will be written especially for you following YOUR EXACT instructions.
100% money back, no questions asked if you paper is plagiarized (this won't happen anyway).
We use a simple but effective principle: one satisfied customer will come back for more, but one who was cheated and misled will tell 10 others too.
Our clients are treated with the highest level of respect that a legitimate student deserves. You, as a customer, will feel this attitude starting from your first contact with our essay service and all the way through.
A significant percentage of cheap essay writing services have also been the source of complaints from students for selling cut and pasted work off the net -- this is a world away from the personalized essay service that EssayPride offers. All our guarantees are always kept -- we are nothing without quality, affordable prices, and the high degree of customer satisfaction!
What our customers say
Piotr S.
Toronto, Canada
I am an ESL student and I am only learning how to write good papers in English. Thanks to EssayPride I am mastering this skill much faster. They help me because they always respond any questions and explain me things I do not understand. They also strictly follow the deadlines and I am never late with my assignments. Thank you very much, guys, your hard work is appreciated. I will surely be ordering more.
Lindsay M.
Winston Salem, NC
Oh my Gosh! My life has become sooo much easier after I've come across this website. I am a working student, so sometimes I am too overwhelmed with so many things and I really need a hand with my papers. I am glad I have found a company I can trust. I have confidence in these guys, because they proved to be good quite a few times.
Kirk N.
Austin, TX
I never leave reviews for products or services because I am quite particular and picky. Surprisingly enough, EssayPride has managed to satisfy all of my requirements, even though I asked for several alterations to the paper they've sent initially. My assignments are quite complicated and it is essential to possess a certain level of knowledge in order to write a decent paper. These guys have managed, so I give them four stars.
Emma Ch.
Birmingham, UK
Customer service is very responsive to your queries, they answer any question within an hour. Even if you have a problem with an order, you can contact them and they will fix it promptly. The quality of writing is very good, writer knows what he is talking about. I had a very positive experience using this website, I will be a returning customer.
Travis J.
Perth, Australia
I used this website more than once and every time my experience turned out to be extremely positive. I think their price-quality ratio is very good, because I couldn't find anyone writing better than these guys, who would work for this money. Thank you!
Myung O.
Seoul, South Korea
I am a Korean student studying in the US. I would like to thank essaypride staff, especially writer Jeff P., for helping me out so much. My grades are good with all your help and I keep calm about the results of my year.
Boyi Zh.
St. Louis, MO
As probably any student, I was quite hesitant about asking somebody else to do my assignments at first. However, after EssayPride has sent me my first paper and I've read it, I understood that I could actually learn a lot from them. The research they've done was impressive and I understood the topic even better than after going to class and reading my textbook. I am not using this website to "cheat", I am using it as a tutoring service, they help me to understand the material better.