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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,cba561cbb713f46f X-Google-Attributes: gid103376,public From: Charles Hixson Subject: Re: Programming Queues in ADA (Very Urgent) Date: 2000/05/10 Message-ID: <3919C745.5AA1ABBC@earthlink.net>#1/1 X-Deja-AN: 621722487 Content-Transfer-Encoding: 8bit References: <8fcfhe$b1d$1@lola.ctv.es> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 957990733 198.94.156.19 (Wed, 10 May 2000 13:32:13 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Wed, 10 May 2000 13:32:13 PDT Newsgroups: comp.lang.ada Date: 2000-05-10T00:00:00+00:00 List-Id: I don't really know the details of your application, but a couple of notes: 1) On many systems rather than deleting and re-allocating nodes it is better to maintain a list of free nodes, then before allocating a new node, one checks to see whether or not the free list is empty. If it is, then one goes ahead and allocates a new node. Otherwise one moves a node from the free node list to the queue. This prevents heap fragmentation, as all nodes are the same size (which all chunks of memory probably wouldn't be.) 2) If you MUST deallocate, check into unchecked_deallocation. 3) I don't know your level of expertise, but just in case, be sure to clean up any pointers (access variables) BEFORE freeing them. S|r |ceman wrote: > H. I need to program a queue in ADA, dont know if queue is the real word in > English, but you will understand FIFO stack I think ;-) > > I dont know who to delete an element from the FIFO stack. I have implemented > it under pointers, and the thing is like this: > > .ADS Stack Specification: > > type NodoCola; > type Puntero is access NodoCola; > > type NodoCola is record > > Elemento: Tipo_Elemento; > Next: Puntero; > > end record; > > type Cola is record > > Registro: Puntero; > NumElem: Natural := 0; > > end record; > > Deleting the element in out position: > > procedure Extraer (C: in out Cola) is > > Aux: Puntero := new NodoCola; > > begin > > Aux := C.Registro; > > if (Es_Vac�a(C)) then > > raise E_Cola_Vac�a; > > else > > C.Registro := C.Registro.Next; > > C.NumElem := C.NumElem - 1; > > end if; > > end Extraer; > > Thank you for helping me with this ;-) > > See ya. > > P.D. If anyone of you could help me, please could you answer into my mailbox > :? Thanks anyway ;-) > > [|] Miguel Angel P�rez (S|r |ceman). > [|] Administrador General de Networking Center(R), 2000 > [|] Email: iceman@webshack-cafe.com > iceman@networking-center.org > admin@networking-center.org > > [|] Networking Center(R) - Proyecto C.I.R.I.T. > > [|] Web: http://www.networking-center.org > [|] FTP: ftp://ftp.networking-center.org > [|] IRC: IRC Hispano, [irc.irc-hispano.org], Canal: #Networking.