By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

how can I find the smallest item in a vector

P: n/a
ken
Hi,

Is there a std algorithm which find the smallest item in a vector?
One way to do it is to use the sort algorithm and then get the first
element.
But what if I just care about the smallest, so I don't care if the
rest of the vector is sorted according.

Is there a more efficient solution to my problem?

Thank you.

Feb 21 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ken
On Feb 20, 8:50 pm, "ken" <ken.carl...@gmail.comwrote:
Hi,

Is there a std algorithm which find the smallest item in a vector?
One way to do it is to use the sort algorithm and then get the first
element.
But what if I just care about the smallest, so I don't care if the
rest of the vector is sorted according.

Is there a more efficient solution to my problem?

Thank you.
Okay I find a solution:
std::min_element

Feb 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.