how to find the last matching element in a container?

S

suresh

Hi
How to find last matching element in a container. The find() algorithm
does it for the first matching element. Of course I can reverse and do
the same..But is there any direct method? I found find_end() but then
that is for matching a sub sequence. But I have just one element to be
matched, but from last. What is the easiest approach?
thanks
suresh
 
Ö

Öö Tiib

Hi
How to find last matching element in a container. The find() algorithm
does it for the first matching element. Of course I can reverse and do
the same..But is there any direct method? I found find_end() but then
that is for matching a sub sequence. But I have just one element to be
matched, but from last. What is the easiest approach?

Depends on container. Reversible containers have rbegin() and rend()
so you can search in reverse order without actually reversing them.
 
S

suresh

Depends on container. Reversible containers have rbegin() and rend()
so you can search in reverse order without actually reversing them.

Thanks, I was trying to use boost::multi_array and they have rbegin()
and rend()
suresh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top