Jump to content
  • Advertisement
Sign in to follow this  
AcidZombie24

iterate in the middle

This topic is 3810 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

stl containers have a .begin() and .end() func. Lets say i want to iterate from index 5000 to 5025th, how would i do this? I dont need to know 5025th, i just want to start at index 5000 instead of 0 and increasing it 5000 times every time i call my iterate func. Maybe i should stick with vector and deque and use the [] feature?

Share this post


Link to post
Share on other sites
Advertisement
For random-access containers you can use begin() + 5000 to get an iterator at that location. For containers that do not give you random-access iterators, however, you'll need to iterate from the beginning to the desired position to get such an iterator.

Share this post


Link to post
Share on other sites
Quote:
Original post by AcidZombie24
Lets say i want to iterate from index 5000 to 5025th, how would i do this?


Why do you think you are going to want to do this?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!