From: Niklas Holsti <niklas.holsti@nospam.please>
Subject: Re: Ada.Containers.Doubly_Linked_Lists
Date: Sun, 04 Feb 2007 10:10:44 +0200
Date: 2007-02-04T10:10:44+02:00 [thread overview]
Message-ID: <45c5937f$0$22514$39db0f71@news.song.fi> (raw)
In-Reply-To: <mailman.67.1170570920.18371.comp.lang.ada@ada-france.org>
Carroll, Andrew wrote:
> Hello,
>
> I would like to understand how to use the Ada.Containers.Doubly_Linked_Lists
> package. After I with Ada.Containers.Doubly_Linked_Lists and then
> declare a variable x: Ada.Containers.Doubly_Linked_Lists.List I get
> the error:
>
> invalid prefix in selected component "doubly_linked_lists".
>
> So, what I'm saying here is that I have no clue how to use the
> Ada.Containers.Doubly_Linked_Lists package and I'm hoping that
> someone here can show me how to use it.
The packages in Ada.Containers are "generic" packages, so you first have
to make an "instance" of Doubly_Linked_Lists before your program can
declare list variables. When you make an instance, you specify which
type of elements the list can hold (Element_Type) and how to compare two
elements for equality (the "=" operator for Element_Type).
See http://en.wikibooks.org/wiki/Ada_Programming/Generics for
explanation and examples of generic packages, and
http://www.adaic.com/standards/05rat/html/Rat-8.html for specific advice
on Ada.Containers.
For example, here is how to make a package that manages lists of Integers:
with Ada.Containers.Doubly_Linked_Lists;
...
package Integer_Lists is
new Ada.Containers.Doubly_Linked_Lists (
Element_Type => Integer);
(I did not give any actual for the formal "=" operator because it
defaults to the predefined "=" for comparing Integers.)
And here is how to declare a variable that holds a list of Integers:
Ints : Integer_Lists.List;
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next parent reply other threads:[~2007-02-04 8:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.67.1170570920.18371.comp.lang.ada@ada-france.org>
2007-02-04 8:10 ` Niklas Holsti [this message]
2007-02-04 21:05 ` Ada.Containers.Doubly_Linked_Lists Jeffrey R. Carter
[not found] <mailman.69.1170624131.18371.comp.lang.ada@ada-france.org>
2007-02-04 21:35 ` Ada.Containers.Doubly_Linked_Lists Niklas Holsti
2007-02-04 22:08 ` Ada.Containers.Doubly_Linked_Lists Ludovic Brenta
2007-02-05 15:43 ` Ada.Containers.Doubly_Linked_Lists Matthew Heaney
2007-02-05 4:03 ` Ada.Containers.Doubly_Linked_Lists Jeffrey R. Carter
2007-02-06 14:40 Ada.Containers.Doubly_Linked_Lists Carroll, Andrew
-- strict thread matches above, loose matches on Subject: below --
2007-02-07 14:52 Ada.Containers.Doubly_Linked_Lists Carroll, Andrew
2007-02-07 15:06 ` Ada.Containers.Doubly_Linked_Lists Ludovic Brenta
2007-02-07 18:22 ` Ada.Containers.Doubly_Linked_Lists Jeffrey R. Carter
2007-02-08 13:39 ` Ada.Containers.Doubly_Linked_Lists Stephen Leake
2007-02-07 18:19 ` Ada.Containers.Doubly_Linked_Lists Jeffrey R. Carter
2007-02-08 10:44 ` Ada.Containers.Doubly_Linked_Lists Alex R. Mosteo
[not found] <mailman.75.1170828524.18371.comp.lang.ada@ada-france.org>
2007-02-07 7:16 ` Ada.Containers.Doubly_Linked_Lists Niklas Holsti
2007-02-08 13:37 ` Ada.Containers.Doubly_Linked_Lists Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox