Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
STL binary search
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Gianni Mariani, post: 1513460"] I believe that std:vector guatentees contiguous elements hence the follwoing holds true: std::vector<T> arr; std::vector<T>::iterator i1; .... int indexof_i1 = &(*i1) - &(*arr.begin()); (iff i1 is an iterator of the arr vector and the vector is not empty) You can often use pointers instead of iterators in many stl algorithms. If you're going to be searching for elements very frequently, it may be that you can use a hashing algorithm and that might be faster. Hope this helps. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
STL binary search
Top