Sign in to follow this  

vector iterator

This topic is 4284 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in my program im using the find(vec.begin,vec.end,search) command to find where an element is in a vector, but find() only returns an iterator. is there a way to get the position of the element that the iterator is pointing to?

Share this post


Link to post
Share on other sites
No, you can't get it directly from the iterator. Why do you want to know the element's index?
There certainly is another way to do it, if of course it really is necessary.

Share this post


Link to post
Share on other sites
thanks, std::distance() works fine. Why would i need it? I'm making a burrwos wheeler transformer and i think it would be quicker to use find() to find a pattern in the block of transformed text than to search the lines of the block.

Share this post


Link to post
Share on other sites

This topic is 4284 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this