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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,80435549e92d4e0c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!213.218.66.70.MISMATCH!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!feeder.xsnews.nl!feeder.news-service.com!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Charles container library usage examples From: David Trudgett Organization: Very little? References: <1125827360.091136.285250@g47g2000cwa.googlegroups.com> Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:fkvwTyHhOZPA1q+vE4yNrmoSDGQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 06 Sep 2005 13:01:14 +1000 NNTP-Posting-Host: 61.8.33.77 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1125975944 61.8.33.77 (Tue, 06 Sep 2005 13:05:44 EST) NNTP-Posting-Date: Tue, 06 Sep 2005 13:05:44 EST Xref: g2news1.google.com comp.lang.ada:4460 Date: 2005-09-06T13:01:14+10:00 List-Id: "Matthew Heaney" writes: > Yes, you need to make two instantiations: one to create a list of > integers, and another to create a map of lists. > > If your list always comprises two elements, then you can use a > constrained array instead. Something like: > > type Integer_Array is array (Positive range <>) of Integer; > subtype Integer_Array_Subtype is Integer_Array (1 .. 2); > > or the simpler: > > type Integer_Array is (1 .. 2) of Integer; Yes, thanks. I used something similar. Using a list didn't give me anything for the extra effort involved. > > Then you can use that as the generic actual Element_Type in the > instantiation of the map (and hence get rid of the list instantiation > entirely). Good idea! ;-) :-) > If you're using an Ada 95 compiler, then you'll have to instantiate the > container packages at "library level," for subtle reasons. (Things are > a lot simpler in Ada 05, and you'll be able to instantiate the > containers in a local scope.) Yes, that will be a lot more convenient. >> When I tried to instantiate a hashed map, it seemed to want me to >> supply a hash function. > > Then just use an ordered map. Subtype Integer has a built-in less-than > operator, so you don't need anything extra to instantiate the ordered > map. Yep. I used the ordered map instead of the hashed map. By the way, does Charles have general purpose hashing functions, or do you need to roll your own? I thought I saw a string hash function in PragmARC. Is it suitable for use in Charles? > (Ada and C++ are low-level, systems programming languages, so we > typically have to think about these things.) Yep. David -- David Trudgett http://www.zeta.org.au/~wpower/ Who would Jesus bomb?