Re: Array foreach in scripting languages
Jon Watte <[email protected]> Sun, 13 Aug 2006 13:05:26 -0700
| Newsgroups | gmane.games.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
What's confusing is that your code uses the name DynamicArray (which I
suppose is close to ArrayList in .NET), and your C++ test sample
probably used std::vector, but you keep referring to the container as a
"list". They are very different kinds of containers.
You will note that C++ allows you to insert and delete objects in a
std::list, but not in a std::vector. The reason is that vectors are
guaranteed to be contiguous, and thus iterators (which may be simple
pointers) would get invalidated when resizing the underlying storage.
Meanwhile, when deleting from a list, the only iterator that gets
invalidated is an iterator pointing to the element being deleted.
Cheers,
/ h+
Carsten Orthbandt wrote:
> The obvious question is how should an active iterator react if the traversed list
> changes? To answer this, I simply tried it out in two languages I know that do
> provide both dynamic arrays and foreach: STL, Tcl and C#.
>
-------------------------------------------------------------------------
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