Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #3287
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.programming |
| References | <c517efb1-d019-439e-ad85-086a999d5ff4@googlegroups.com> <72265d42-b411-47e2-bd5b-8b4929059354@googlegroups.com> |
| Subject | Re: iterate and delete |
| Message-ID | <gXUit.16640$ew7.8691@fx16.fr7> (permalink) |
| Organization | virginmedia.com |
| Date | 2013-05-09 22:53 +0100 |
<malcolm.mclean5@btinternet.com> wrote in message news:72265d42-b411-47e2-bd5b-8b4929059354@googlegroups.com... > On Monday, May 6, 2013 7:13:35 PM UTC+1, bob wrote: >> Does computer science in general ever address the issue of when you are >> iterating over a collection and deleting elements from it? If you are >> just >> using a counter, this can be tricky as the deletions can mess up the >> indices. >> > It's something that people who teach computer science in universities are > well aware of. > However it tends to be glossed over at an introductory level to avoid > overloading students with difficulties. Deleting or, more rarely, adding > elements can make it very difficult to keep iterators up to date. Surely it's impossible to deal with it in general? Since any collection could be transformed, in between one iteration and the next, into a totally different collection. The current position or element in the old collection might then be meaningless. -- Bartc
Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll thread
iterate and delete bob <bob@coolfone.comze.com> - 2013-05-06 11:13 -0700
Re: iterate and delete JJ <duh@nah.meh> - 2013-05-07 03:35 +0700
Re: iterate and delete Rui Maciel <rui.maciel@gmail.com> - 2013-05-07 09:39 +0100
Re: iterate and delete bob <bob@coolfone.comze.com> - 2013-05-08 07:54 -0700
Re: iterate and delete malcolm.mclean5@btinternet.com - 2013-05-09 07:58 -0700
Re: iterate and delete "BartC" <bc@freeuk.com> - 2013-05-09 22:53 +0100
csiph-web