|
-
December 20th, 2011, 03:05 PM
#1
[RESOLVED] find in vectors
I have a vector of numbers arranged in increasing order. I need to find the exact location where first time the number in vector exceeds a certain value.
This vector is expected to be of size 10^6 and I was wondering if there is an automatic function of finding the above index without a for loop.
Thanks
-
December 20th, 2011, 03:27 PM
#2
Re: find in vectors
 Originally Posted by Learned
I have a vector of numbers arranged in increasing order. I need to find the exact location where first time the number in vector exceeds a certain value.
This vector is expected to be of size 10^6 and I was wondering if there is an automatic function of finding the above index without a for loop.
Thanks
std::upper_bound
http://www.cplusplus.com/reference/a...m/upper_bound/
Regards,
Paul McKenzie
-
December 20th, 2011, 03:28 PM
#3
Re: find in vectors
Perhaps the lower_bound function will get you what you want?
Viggy
PS. Paul beat me to it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|