CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Location
    NY, USA
    Posts
    191

    [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

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: find in vectors

    Quote Originally Posted by Learned View Post
    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

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    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
  •  





Click Here to Expand Forum to Full Width

Featured