From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?B?QmrDtnJuIEx1bmRpbg==?= Newsgroups: comp.lang.ada Subject: Re: container of a container... Date: Sat, 01 Aug 2015 13:56:46 +0200 Organization: A noiseless patient Spider Message-ID: References: <790f92b6-56fc-4dfb-81c7-39b11a1b9ae0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 1 Aug 2015 11:53:24 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="5971bc866c55926cf3b38dffb7b7db42"; logging-data="29868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S2319E4gV0xg0Zycy6FTv" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 In-Reply-To: <790f92b6-56fc-4dfb-81c7-39b11a1b9ae0@googlegroups.com> Cancel-Lock: sha1:xLUTxuPK7lpZMZzeeZLhtq3xD74= Xref: news.eternal-september.org comp.lang.ada:27296 Date: 2015-08-01T13:56:46+02:00 List-Id: On 2015-07-31 23: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... > > --Below creates a map, keyed on 2 character length strings --and hold a list of integers; --it also prints the items of each list in the two map-entries with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers.Hashed_Maps; with Ada.Strings; with Ada.Strings.Hash; with Text_Io; procedure Lists is package Integer_Pack is new Ada.Containers.Doubly_Linked_Lists(integer); subtype String_Key_Type is String(1..2); package List_Maps is new Ada.Containers.Hashed_Maps ( String_Key_Type, Integer_Pack.List, Ada.Strings.Hash, "=", Integer_Pack."="); Map : List_Maps.Map ; Integer_List : Integer_Pack.List; begin for i in 1 .. 20 loop Integer_List.Append(i); end loop; Map.Insert("12", Integer_List); Integer_List.Clear; for i in 21 .. 40 loop Integer_List.Append(i); end loop; Map.Insert("11", Integer_List); for L of map("11") loop Text_Io.Put_Line(L'img); end loop; for L of map("12") loop Text_Io.Put_Line(L'img); end loop; end Lists; -- -- Björn