From: Carroll, Andrew on 4 Feb 2007 16:21 Ahhhhh, I see. Okay, so, just out of curiosity, what do I do if I need the Node_type within Ada.Containers.Doubly_Linked_Lists to have an additional "attribute"? So instead of just having type Node_Type is limited record Element : Element_Access; Next : Node_Access; Prev : Node_Access; end record; what if I want type Node_Type is limited record Name : ada.strings.unbounded.unbounded_string; Element : Element_Access; Next : Node_Access; Prev : Node_Access; end record; How do I do that? Andrew
From: Niklas Holsti on 4 Feb 2007 16:35 Carroll, Andrew wrote: > Ahhhhh, I see. (Please quote a bit of the post to which you are replying so that the context of your "Ahhhhh" is clearer :-) > Okay, so, just out of curiosity, what do I do if I need the > Node_type within Ada.Containers.Doubly_Linked_Lists to > have an additional "attribute"? What Node_Type? Are you peeking at the *private* part of Ada.Containers.Doubly_Linked_Lists, or even at the source-code of the body of the generic? That's useless because you can't access the private stuff or the stuff in the body. Whatever you want to keep in your list, put it in your Element_Type, the type that you use to instantiate Doubly_Linked_Lists. For example, make it a record type and put in whatever components you need. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .
From: Ludovic Brenta on 4 Feb 2007 17:08 Niklas Holsti <niklas.holsti(a)nospam.please> writes: > Carroll, Andrew wrote: >> Ahhhhh, I see. > > (Please quote a bit of the post to which you are replying so that the > context of your "Ahhhhh" is clearer :-) > >> Okay, so, just out of curiosity, what do I do if I need the >> Node_type within Ada.Containers.Doubly_Linked_Lists to >> have an additional "attribute"? > > What Node_Type? Are you peeking at the *private* part of > Ada.Containers.Doubly_Linked_Lists, or even at the source-code of the > body of the generic? That's useless because you can't access the > private stuff or the stuff in the body. > > Whatever you want to keep in your list, put it in your Element_Type, > the type that you use to instantiate Doubly_Linked_Lists. For example, > make it a record type and put in whatever components you need. And, if Niklas' answer was unclear, do not add Prev or Next to your Element_Type; it is the generic linked list's job to add and manage them. If all you want is an unbounded string, just say package Lists_Of_Unbouned_Strings is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Ada.Strings.Unbounded.Unbounded_Strings); L : Lists_Of_Unbouned_Strings.List; and off you go. -- Ludovic Brenta.
From: Jeffrey R. Carter on 4 Feb 2007 23:03 Carroll, Andrew wrote: > > Okay, so, just out of curiosity, what do I do if I need the Node_type > within Ada.Containers.Doubly_Linked_Lists to have an additional > "attribute"? So instead of just having > > type Node_Type is limited record > Element : Element_Access; > Next : Node_Access; > Prev : Node_Access; > end record; There is nothing named Node_Type in Ada.Containers.Doubly_Linked_Lists. See ARM-0X A.18.3 for the definition of this generic package: http://www.adaic.org/standards/05rm/html/RM-A-18-3.html An implementation may have something named Node_Type, but that would not be in the visible part of the specification, and so unavailable to you as a client of the generic or instantiations of it. Another implementation may be completely different, so relying on information about the implementation would be completely non-portable. -- Jeff Carter "Now go away or I shall taunt you a second time." Monty Python & the Holy Grail 07
From: Matthew Heaney on 5 Feb 2007 10:43
On Feb 4, 5:08 pm, Ludovic Brenta <ludo...(a)ludovic-brenta.org> wrote: > If all you want is an unbounded string, just say > > package Lists_Of_Unbouned_Strings is > new Ada.Containers.Doubly_Linked_Lists > (Element_Type => Ada.Strings.Unbounded.Unbounded_Strings); > > L : Lists_Of_Unbouned_Strings.List; A cleaner way to do this (that avoids having to use type Unbounded_String) is: package String_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String); procedure Op (L : String_Lists.List) is begin L.Append ("Hello, World!"); end; |