Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #3287

Re: iterate and delete

Path csiph.com!usenet.pasdenom.info!goblin1!goblin.stu.neva.ru!news.astraweb.com!border6.a.newsrouter.astraweb.com!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!npeersf03.am4!fx16.fr7.POSTED!not-for-mail
From "BartC" <bc@freeuk.com>
Newsgroups comp.programming
References <c517efb1-d019-439e-ad85-086a999d5ff4@googlegroups.com> <72265d42-b411-47e2-bd5b-8b4929059354@googlegroups.com>
In-Reply-To <72265d42-b411-47e2-bd5b-8b4929059354@googlegroups.com>
Subject Re: iterate and delete
Lines 1
MIME-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 7bit
X-Priority 3
X-MSMail-Priority Normal
Importance Normal
X-Newsreader Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE Produced By Microsoft MimeOLE V14.0.8089.726
X-Antivirus avast! (VPS 130509-0, 09/05/2013), Outbound message
X-Antivirus-Status Clean
Message-ID <gXUit.16640$ew7.8691@fx16.fr7> (permalink)
NNTP-Posting-Host 82.38.16.70
X-Complaints-To http://netreport.virginmedia.com
X-Trace 1368136524 82.38.16.70 (Thu, 09 May 2013 21:55:24 UTC)
NNTP-Posting-Date Thu, 09 May 2013 21:55:24 UTC
Organization virginmedia.com
Date Thu, 9 May 2013 22:53:41 +0100
X-Received-Bytes 2130
Xref csiph.com comp.programming:3287

Show key headers only | View raw



<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


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