From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.111.132 with SMTP id ii4mr6032115obb.2.1425494335068; Wed, 04 Mar 2015 10:38:55 -0800 (PST) X-Received: by 10.140.100.230 with SMTP id s93mr104419qge.1.1425494334893; Wed, 04 Mar 2015 10:38:54 -0800 (PST) Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!hl2no4237022igb.0!news-out.google.com!qk8ni49443igc.0!nntp.google.com!k15no212423qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 4 Mar 2015 10:38:54 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.99.113.5; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 83.99.113.5 References: <7ffd1bf0-b815-474d-a4f2-cf471db0be37@googlegroups.com> <3a73a17d-2c37-47d2-9049-522632c24c15@googlegroups.com> <2a87cf3b-8621-4f5e-89a5-be4045eba583@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why does that work? From: Laurent Injection-Date: Wed, 04 Mar 2015 18:38:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:192413 Date: 2015-03-04T10:38:54-08:00 List-Id: On Wednesday, March 4, 2015 at 6:35:55 PM UTC+1, Simon Wright wrote: > David Botton writes: > > >> Ah great again a case of the lights are on but nobody at home. > > > > Rude. > > I think OP is allowed to be rude about himself! Right. I am always amazed who different my thinking is when I suffer under a f*cking migraine attack. Even if the pain is gone by swallowing some pills but the logic is still suffering :( procedure Remove_Node (It : in Iterator) is Temp : List_Ptr := It.This; begin -- Remove_Node if It.This = null then -- List is empty or no node found Ada.Text_IO.Put_Line ("No item to delete"); elsif It.This.Previous = null then -- case 1: It = First node It.L.Head := It.This.Next; It.This.Next.Previous:= null; Dispose (X => Temp); elsif It.This.Next = null then -- case 2: It = Last node It.L.Tail := It.This.Previous; It.This.Previous.Next := null; Dispose (X => Temp); else -- case 3: It is an intermediate node It.This.Previous.Next := It.This.Next; It.This.Next.Previous := It.This.Previous; Dispose (X => Temp); end if; end Remove_Node; It is this procedure which works differently than I expected. Because I have no direct access to the list L and its head/tail. The first one I posted doesn't even need an iterator. The first solution I figured out was horrible and allowed something stupid like searching in L3 but trying to delete in L2 : GL_Int.Remove_Node (List=> L3'Access, It => Aux_IO.Search (L => L3'Access, Element => Search_For)); But using the iterator I have a workaround but I don't understand how that is possible. GL_Int.Remove_Node ( It => Aux_IO.Search (L => L3'Access, Element => Search_For)); I thought that the iterator is part of the list but that could be wrong. So the list is part of the iterator. Aka it is not the spaceship which moves but the universe around it? (sry couldn't resist citing the explanation from Futurama((tm))). So if someone could clarify this. Thanks Laurent