Advertisement Jump to content
Sign in to follow this  
_Vicious_

Builtin range/collection type

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

Hello fellow AngelScripters,

now that we have 'auto' keyword support thanks to GGLucas ( http://www.gamedev.net/topic/652525-experimental-patches-named-arguments-and-auto-declarations/ ) maybe we could start thinking on how it'd be best to implement iteratable ranges/collection types in AS? For example, it'd be nice to be able to iterate in the following manner:
 

uint maxPlayers;
...
for( auto playerIndex : range<int>(0,maxPlayers-1) ) {

or even
 

array <Player @> players;
...
for( auto @Player : players ) {

I'm using C++11 syntax here but there might be other alternatives.

Any thoughts or suggestions?

Edited by _Vicious_

Share this post


Link to post
Share on other sites
Advertisement

The most difficult part of this is to create safe iterators. The implementation of the iterators must guarantee a proper behaviour even if the object that is being iterated is modified from somewhere else while it is being iterated.

Share this post


Link to post
Share on other sites

It appears to me that deleting or inserting an element in collection preceeding the iterator internal pointer should increment or decrement the pointer accordingly. Iterator should also hold reference to the collection and the currently pointed element too if it's refcounted. Nothing else has come to my mind so far.

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!