comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: container of a container...
Date: Sat, 01 Aug 2015 00:48:38 +0300
Date: 2015-08-01T00:48:38+03:00	[thread overview]
Message-ID: <d228pmFs28lU1@mid.individual.net> (raw)
In-Reply-To: <790f92b6-56fc-4dfb-81c7-39b11a1b9ae0@googlegroups.com>

On 15-08-01 00:13 , Hedley Rainnie wrote:
> Is it possible to code that? I am coming from the C++ STL world
> where, it  relatively easy to put that together. (a vector of lists
> as an example).
>
> There are many wonderful examples for Ada containers (stacks etc).
> But I have not seen any container[container[...]..] examples.
>
> Being new to Ada, I am sure I have missed something obvious...


Example of a vector of lists of characters:

with Ada.Containers.Vectors;
with Ada.Containers.Doubly_Linked_Lists;

procedure Vec_List
is

    package Char_Lists is new Ada.Containers.Doubly_Linked_Lists (
       Element_Type => Character);

    package Char_List_Vectors is new Ada.Containers.Vectors (
       Index_Type   => Positive,
       Element_Type => Char_Lists.List,
       "="          => Char_Lists."=");

    Vec : Char_List_Vectors.Vector;

    ABC : Char_Lists.List;

begin

    ABC.Append ('A');
    ABC.Append ('B');
    ABC.Append ('C');

    Vec.Replace_Element (3, ABC);

end Vec_List;


-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  reply	other threads:[~2015-07-31 21:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 21:13 container of a container Hedley Rainnie
2015-07-31 21:48 ` Niklas Holsti [this message]
2015-08-01 11:56 ` Björn Lundin
replies disabled

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