comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: ANN: Simple components v 1.3
Date: Thu, 15 Jan 2004 16:04:18 +0100
Date: 2004-01-15T16:04:18+01:00	[thread overview]
Message-ID: <629d00tlqvu326hi1vsomlmnvkobvbc0bl@4ax.com> (raw)
In-Reply-To: matsw-8893DA.15010415012004@sicinfo.epfl.ch

On Thu, 15 Jan 2004 15:01:05 +0100, Mats Weber <matsw@bluewin.ch>
wrote:

>In article <75ga001eokc2r1aijtvu9d70ck3i6j1p0m@4ax.com>,
> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>
>>>> This release includes generic maps (associative arrays)
>
>>http://www.dmitry-kazakov.de/ada/components.htm
>
>I have been working on this (generic maps) for quite a while (and a long 
>time ago). What I came up with is that the generic formal key type must 
>be limited private and unconstrained (<>) for the component to be 
>useable in most situations.
>
>Here is the generic formal part of my version of maps:
>
>generic
>   type Key_Type (<>) is limited private;
>   type Item_Type is private;
>   with function Key_Of (Item : in Item_Type) return Key_Type;
>   with function "=" (X, Y : Key_Type) return Boolean is <>;
>   with function "<" (X, Y : Key_Type) return Boolean is <>;
>   type Count is range <>;    -- must include 0
>package Bags is
>   ...
>
>The big differences is that there is no constraint on Key_Type and that 
>the key is part of each item and is extracted from it with the generic 
>formal function Key_Of. 
>
>For instance, you can have Key_Type => String, with the above, which you 
>cannot do with your version.

Isn't it same as to have just set rather than map? I have Generic_Set:

generic
   type Object_Type is private;
   Null_Element : Object_Type;
    ...
   with function "<" (Left, Right : Object_Type) return Boolean is <>;
   with function "=" (Left, Right : Object_Type) return Boolean is <>;
package Generic_Set is

Here elements are comparable without mentioning any key type.

I have added Generic_Map only after realizing that sometimes it is
necessary to have different ordering strategies for the same object
type and that the key is not always deducible from the object it
points to.

--
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2004-01-15 15:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-03 17:17 ANN: Simple components v 1.3 Dmitry A. Kazakov
2004-01-14 12:06 ` Preben Randhol
2004-01-14 13:15   ` Dmitry A. Kazakov
2004-01-15 14:01     ` Mats Weber
2004-01-15 15:04       ` Dmitry A. Kazakov [this message]
2004-01-15 16:22         ` Mats Weber
2004-01-15 18:18           ` Jeffrey Carter
2004-01-16  9:49           ` Dmitry A. Kazakov
replies disabled

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