comp.lang.ada
 help / color / mirror / Atom feed
From: "Ricardo Palomares Martínez" <ricardo@eucmax.sim.ucm.es>
To: Matt Tyler <matt_tyler@hotmail.com>
Subject: Re: Doubly linked list (again, sorry)
Date: 1998/12/16
Date: 1998-12-16T00:00:00+00:00	[thread overview]
Message-ID: <3677A69C.C197C703@eucmax.sim.ucm.es> (raw)
In-Reply-To: 7580p3$q00@romeo.logica.co.uk

Matt Tyler wrote:

> Hello.
>
> I have created a doubly linked list. With the procedure (body only)
>
> List:=new cell'(V,Next=>, Prev=>null);
>
> (...)
>
>
> To loop from start of list do I need to create a (say) Start_of_list access
> type to the first cell in the list or is there a more elegant way that I am
> missing.

    You should have a pointer to the first element of the list and other to the
last one. You also need another pointer to the current element when walking
through the list.


> Also, when I remove (to delete) a record from the list do I have to
> de-allocate the memory occupied by the object or is it done for me.

    You need to de-allocate it. I can't recall it right, but it has to do with
Unchecked_Deallocation package or similar. Anyway, read the end of my message.


> I am sorry to waste your time but I am having a few problems with access
> types. Thanks in advance

    You seem to have some lack of knowledge about the basics of the
double-linked lists, rather than implementing it in Ada. Perhaps you may wish to
give a look to some data structure or programming books (Knuth: "Data structures
+ Algorithms = Programs" IIRC, or Schultz: "Data Structures"; there is a long
time since I had my hands over these books and the title may be inaccurate).
Anyway, the newsgroups are to help us each other.

    About the double-linked list, I wrote a generic package to implement
double-linked list with n indexes (ie, n different pairs of pathways to run
through the list; think of every element as a link of a chain: then, every index
lets you put the links in a different order to form the chain). The generic
package lets you use any data type. It is not really a fast implementation,
because due to the nature of the package, you can't access directly to the
pointer type; instead, you have an identifier to which you refer always you need
to access a specific element, and internally to the package the list is walked
until the element is found.

    So, if you have big trouble implementing a double-linked list I can send the
code to you (the identifiers and comments are in spanish, but I can translate
the more important things if you want).

HTH

--
Ricardo Palomares Martínez -------- mailto:ricardo@eucmax.sim.ucm.es
UCM - Servicio Informático Gestión -- http://www.ucm.es/info/gstwsig





  reply	other threads:[~1998-12-16  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-16  0:00 Doubly linked list (again, sorry) Matt Tyler
1998-12-16  0:00 ` Ricardo Palomares Martínez [this message]
1998-12-17  0:00   ` Mats Weber
1998-12-18  0:00     ` Ricardo Palomares Martínez
1998-12-17  0:00   ` bwefler
replies disabled

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