Re: Array foreach in scripting languages
Jon Watte <[email protected]> Mon, 14 Aug 2006 10:15:34 -0700
| Newsgroups | gmane.games.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
Carsten Orthbandt wrote:
> I tested this with both, my DynamicArray and std::vector.
> Since we're talking about a scripting language here, the
> actual implementation doesn't matter. It can be alinked
> list, contigous memory block, hashmap, whatever.
>
The actual implementation DOES matter, because std::list<> makes the
guarantee that you can delete items ahead of, or behind, the current
iterator, without ill effects. An array, on the other hand, explicitly
forbids that practice.
Thus, depending on which semantic you prefer to expose, you should
choose one, or the other. That's one of the reasons that C++ defines
both data types, and lets the programmer decide.
In the case where you're using a data type that invalidates iterators, I
suggest that you (at least in debug mode) detect the invalid iterator
and assert out on first use. The sooner you detect potentially invalid
usage, the better.
Cheers,
/ h+
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555