Question

Implement the STL find routine that returns the iterator containing the first occurrence of x in...

Implement the STL find routine that returns the iterator containing the first occurrence of x in the range that begins at start and extends up to but not including end. If x is not found, end is returned. This is a nonclass (global function) with signature

template <typename Iterator, typename Object>

iterator find( Iterator start, Iterator end, const Object & x );

Homework Answers

Answer #1

Here is the completed code for this method. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks


//required template method
template <typename Iterator, typename Object>
Iterator find( Iterator start, Iterator end, const Object & x ){
        //looping until start and end are same
        while(start!=end){
                //checking if value associated with start iterator is x
                if(*start == x){
                        return start; //found, returning start
                }
                //else, advancing start to next position
                start++;
        }
        return end; //not found
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich,...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich, O. C. Ferrell, and Jennifer Jackson, with the editorial assistance of Jennifer Sawayda. This case was developed for classroom discussion rather than to illustrate either effective or ineffective handling of an administrative, ethical, or legal discussion by management. All sources used for this case were obtained through publicly available material. Mattel, Inc. is a world leader in the design, manufacture, and marketing of family...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT