comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Charles container library usage examples
Date: Sat, 03 Sep 2005 05:15:45 GMT
Date: 2005-09-03T05:15:45+00:00	[thread overview]
Message-ID: <u4q92buke.fsf@earthlink.net> (raw)
In-Reply-To: m3slwm6fkm.fsf@rr.trudgett

David Trudgett <wpower@zeta.org.au.nospamplease>  writes:

> Does anyone know where I can find some usage examples for the Charles
> container library, or some code that makes use of Charles?

Here's my Ada-Europe 2004 tutorial:

http://charles.tigris.org/charles_tutorial.ppt
http://charles.tigris.org/charles_tutorial.pdf

My original AI-302 proposal was based on Charles, and contains many
examples:

http://home.earthlink.net/~matthewjheaney/charles/ai302.txt


> I've got Charles downloaded and installed on my include path, but as a
> newcomer to Ada, I'm having difficulty working out how it is intended
> to be used.

Charles is more or less a port of the STL to Ada95, so if you can follow
an STL tutorial (there are lots of them on the web), then you shouldn't
have any problem extrapolating that to Charles.

The standard container library has changed significantly from my
original proposal, but even so you should be able to follow the AI-302
examples:

http://charles.tigris.org/source/browse/charles/src/ai302/examples/


> The first thing I had in mind to do was to create a simple map, for
> example, to translate the following Common Lisp:
> 
> (defvar *side-corners*
>   '((2 (1 3))
>     (4 (1 7))
>     (6 (3 9))
>     (8 (7 9))))

You can use a map, instantiated with type Integer as the key and an
instantiation of a list as the element.  Either the hashed map or the
ordered map would suffice.


> This is just a simple mapping of four particular integers (2, 4, 6, 8)
> to four particular lists each consisting of two integers.
> 
> I use it in a function like this:
> 
> (defun side-corners (side)
>   "Return a list of the (two) corners that flank the given side"
>   (second (assoc side *side-corners*)))
> 
> so that the function call
> 
> (side-corners 2)
> 
> returns the list (1 3)

Something like (I have omitted a few steps):

procedure Op (Map : Container_Type) is
   I : constant Iterator_Type := Find (Map, Key => 2);
   L : List_Types.Container_Type renames To_Access (I).all;
begin
   ...
end;

This is similar to the C++ code:

void f(const map_t& m)
{
   const map_t::const_iterator i = m.find (2);
   const list_t& L = *i;
   //...
}


> Any pointers to code samples, or other hints would be greatly
> appreciated!

Send me email (or continue posting to CLA) if you need any help.

-Matt



  reply	other threads:[~2005-09-03  5:15 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 [this message]
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
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