* Re: Programming Queues in ADA (Very Urgent)
2000-05-10 0:00 Programming Queues in ADA (Very Urgent) S|r |ceman
2000-05-10 0:00 ` Ted Dennison
@ 2000-05-10 0:00 ` Charles Hixson
1 sibling, 0 replies; 6+ messages in thread
From: Charles Hixson @ 2000-05-10 0:00 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Programming Queues in ADA (Very Urgent)
2000-05-10 0:00 Programming Queues in ADA (Very Urgent) S|r |ceman
@ 2000-05-10 0:00 ` Ted Dennison
2000-05-11 0:00 ` David C. Hoos, Sr.
2000-05-10 0:00 ` Charles Hixson
1 sibling, 1 reply; 6+ messages in thread
From: Ted Dennison @ 2000-05-10 0:00 UTC (permalink / raw)
In article <8fcfhe$b1d$1@lola.ctv.es>,
"S|r |ceman" <aquakill@teleline.es> wrote:
> I dont know who to delete an element from the FIFO stack. I have
> implemented it under pointers, and the thing is like this:
>
> Aux: Puntero := new NodoCola;
If you want to dynamicly get rid of objects created with "new", you
probably want to use an instantiation of the generic function
"Unchecked_Conversion". Look up that name in your Ada textbook for more
information.
--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Programming Queues in ADA (Very Urgent)
@ 2000-05-10 0:00 S|r |ceman
2000-05-10 0:00 ` Ted Dennison
2000-05-10 0:00 ` Charles Hixson
0 siblings, 2 replies; 6+ messages in thread
From: S|r |ceman @ 2000-05-10 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Programming Queues in ADA (Very Urgent)
2000-05-10 0:00 ` Ted Dennison
@ 2000-05-11 0:00 ` David C. Hoos, Sr.
2000-05-11 0:00 ` Pascal Obry
2000-05-11 0:00 ` Ted Dennison
0 siblings, 2 replies; 6+ messages in thread
From: David C. Hoos, Sr. @ 2000-05-11 0:00 UTC (permalink / raw)
> If you want to dynamicly get rid of objects created with "new", you
> probably want to use an instantiation of the generic function
> "Unchecked_Conversion".
Whaaat????????????????
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Programming Queues in ADA (Very Urgent)
2000-05-11 0:00 ` David C. Hoos, Sr.
2000-05-11 0:00 ` Pascal Obry
@ 2000-05-11 0:00 ` Ted Dennison
1 sibling, 0 replies; 6+ messages in thread
From: Ted Dennison @ 2000-05-11 0:00 UTC (permalink / raw)
In article <83pS4.46959$x4.1574777@newsread1.prod.itd.earthlink.net>,
"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote:
> > If you want to dynamicly get rid of objects created with "new", you
> > probably want to use an instantiation of the generic function
> > "Unchecked_Conversion".
> Whaaat????????????????
Dooooh! "Uchecked_Deallocation" of course. An honest mistake, but it
probably confused the heck out of our poor student...
--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html
Sent via Deja.com http://www.deja.com/
Before you buy.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Programming Queues in ADA (Very Urgent)
2000-05-11 0:00 ` David C. Hoos, Sr.
@ 2000-05-11 0:00 ` Pascal Obry
2000-05-11 0:00 ` Ted Dennison
1 sibling, 0 replies; 6+ messages in thread
From: Pascal Obry @ 2000-05-11 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]
David C. Hoos, Sr. <david.c.hoos.sr@ada95.com> a �crit dans le message :
83pS4.46959$x4.1574777@newsread1.prod.itd.earthlink.net...
> > If you want to dynamicly get rid of objects created with "new", you
> > probably want to use an instantiation of the generic function
> > "Unchecked_Conversion".
> Whaaat????????????????
>
No worry, I'am sure Ted was thinking about Unchecked_Deallocation :)
Pascal.
--
--|------------------------------------------------------------
--| Pascal Obry Team-Ada Member |
--| |
--| EDF-DER-IPN-SID- T T I |
--| Intranet: http://cln46gb |
--| Bureau N-023 e-mail: p.obry@der.edf.fr |
--| 1 Av G�n�ral de Gaulle voice : +33-1-47.65.50.91 |
--| 92141 Clamart CEDEX fax : +33-1-47.65.50.07 |
--| FRANCE |
--|------------------------------------------------------------
--|
--| http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-05-11 0:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-10 0:00 Programming Queues in ADA (Very Urgent) S|r |ceman
2000-05-10 0:00 ` Ted Dennison
2000-05-11 0:00 ` David C. Hoos, Sr.
2000-05-11 0:00 ` Pascal Obry
2000-05-11 0:00 ` Ted Dennison
2000-05-10 0:00 ` Charles Hixson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox