From: David Trudgett <wpower@zeta.org.au.nospamplease>
Subject: Re: Charles container library usage examples
Date: Tue, 06 Sep 2005 13:01:14 +1000
Date: 2005-09-06T13:01:14+10:00 [thread overview]
Message-ID: <m3vf1eq4qt.fsf@rr.trudgett> (raw)
In-Reply-To: 1125827360.091136.285250@g47g2000cwa.googlegroups.com
"Matthew Heaney" <mheaney@on2.com> 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?
next prev parent reply other threads:[~2005-09-06 3:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-03 2:38 Charles container library usage examples David Trudgett
2005-09-03 5:15 ` Matthew Heaney
2005-09-03 9:45 ` Simon Wright
2005-09-04 6:25 ` David Trudgett
2005-09-05 11:28 ` Georg Bauhaus
2005-09-04 0:26 ` David Trudgett
2005-09-04 9:49 ` Matthew Heaney
2005-09-06 3:01 ` David Trudgett [this message]
2005-09-06 16:22 ` Jeffrey Carter
2005-09-07 0:15 ` Matthew Heaney
2005-09-04 17:19 ` Ludovic Brenta
2005-09-06 3:01 ` David Trudgett
2005-09-06 5:08 ` Ludovic Brenta
2005-09-06 6:46 ` David Trudgett
2005-09-06 7:26 ` Ludovic Brenta
2005-09-24 0:05 ` Randy Brukardt
2005-09-09 14:57 ` James Alan Farrell
2005-09-10 7:38 ` David Trudgett
2005-09-10 14:55 ` Matthew Heaney
2005-09-10 15:26 ` Ludovic Brenta
2005-09-10 17:58 ` Matthew Heaney
2005-09-12 0:24 ` Robert A Duff
2005-09-11 10:52 ` Georg Bauhaus
2005-09-11 21:14 ` David Trudgett
2005-09-13 23:41 ` Björn Persson
2005-09-14 6:39 ` David Trudgett
2005-09-12 0:21 ` Robert A Duff
2005-09-12 0:57 ` David Trudgett
2005-09-12 1:01 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox