comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: how to delete from Ada.Containers.Doubly_Linked_Lists
Date: Tue, 19 Aug 2014 10:56:25 +0200
Date: 2014-08-19T10:56:25+02:00	[thread overview]
Message-ID: <lsv3fa$k4v$1@dont-email.me> (raw)
In-Reply-To: <lstlqr$ks3$1@dont-email.me>

On 2014-08-18 21:57, Jeffrey Carter wrote:
> On 08/18/2014 11:51 AM, Björn Lundin wrote:

>> How should a nice solution look like ?
> 
> You probably ought to read about "tampering with cursors" in the ARM (A.18.3).
> In your case, iterating over the list needs the list to remain unchanged until
> iteration finishes. Deleting during iteration would violate this.

Hmm, yes I see that now.

> This restriction is intended for safety, and sometimes seems onerous.

That was my suspicion

> I've had
> to iterate over one data structure, storing cursors in another data structure,
> then iterate over the 2nd data structure to delete using the stored cursors.

Yes, basically what my last sample did - saving the cursor 'c' into
'C_Save' and delete outside the loop. That is what I thought was
inelegant/clumpsy

> You can delete during iteration if you don't invoke an Iterate subprogram:

Still a bit inelegant, but thanks for the example.
It is way better that mine.


/Björn






      reply	other threads:[~2014-08-19  8:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-18 18:51 how to delete from Ada.Containers.Doubly_Linked_Lists Björn Lundin
2014-08-18 19:57 ` Jeffrey Carter
2014-08-19  8:56   ` Björn Lundin [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox