From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: Spellcheck.adb
Date: Wed, 27 Apr 2005 11:11:06 -0400
Date: 2005-04-27T15:11:07+00:00 [thread overview]
Message-ID: <426fab8a$0$3712$39cecf19@news.twtelecom.net> (raw)
In-Reply-To: 1114548638.851249.246280@f14g2000cwb.googlegroups.com
"Albert Bachmann" <albert.bachmann@gmx.de> wrote in message
news:1114548638.851249.246280@f14g2000cwb.googlegroups.com...
>
> In the meantime I followed the advice from Matthew Heaney (thanks
> Matthew) and went on with Ada.Containers. I again tried a simple
> implementation. Unfortunately I recognized that controlled types have
> to be instantiated at library level
This is no longer true in Ada 2005. Eventually you'll be able to
instantiate the containers in your main subprogram.
> which requires now a total of 3
> files since the instantiation of ada.containers.hashed_maps needs a
> definite subtype for its key_type.
True, but that's why we have the Indefinite_Hashed_Maps container package.
If you're manipulating strings, you should probably be using that.
Also, as I mentioned in an earlier post, you don't really need a map, since
all you're doing is performing a membership test. Hence, a (hashed) set
will do.
> types.ads:
> ----------
>
> package types is
> subtype word is string(1 .. 128);
> end types;
Get rid of this. Instantiate the Indefinite_Hashed_Sets (or _Maps, if you
prefer) with type String.
> hashmap.ads:
> ------------
>
> package hashmap is new ada.containers.hashed_maps(key_type =>
> types.word,
No. This should just be type String.
> and finally spellcheck2.adb:
> ----------------------------
>
> strings.fixed.delete(item, item_offset + 1, word'last);
You can get rid of this.
> hashmap.insert(dict, item, true);
If you used a (hashed) set, then all you'd have to say is
insert(dict, item);
> strings.fixed.delete(item, item_offset + 1, word'last);
You can get rid of this.
> if not hashmap.contains(dict, item) then
See, you're not using the map element at all. You're only using the key.
> Please note that those attempts are only quick and dirty hacks. If
> someone knows how to get rid of the seperate types.ads file I would
> welcome his advice.
You can get rid of the types file, by using the indefinite hashed map (or
set), and instantiating it with type String.
-Matt
next prev parent reply other threads:[~2005-04-27 15:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-25 21:30 [Shootout] Spellcheck.adb albert.bachmann
2005-04-25 21:57 ` Spellcheck.adb Albert Bachmann
2005-04-25 23:27 ` [Shootout] Spellcheck.adb Marius Amado Alves
2005-04-26 18:04 ` Spellcheck.adb Matthew Heaney
2005-04-26 19:36 ` [Shootout] Spellcheck.adb David Sauvage
2005-04-26 20:50 ` Spellcheck.adb Albert Bachmann
2005-04-27 15:11 ` Matthew Heaney [this message]
2005-04-27 22:49 ` Spellcheck.adb Albert Bachmann
2005-04-27 23:35 ` Spellcheck.adb Marius Amado Alves
2005-04-27 23:58 ` Spellcheck.adb Albert Bachmann
2005-04-28 0:19 ` Spellcheck.adb Marius Amado Alves
2005-04-29 10:22 ` Spellcheck.adb Albert Bachmann
2005-04-28 0:58 ` Spellcheck.adb Matthew Heaney
2005-04-29 10:19 ` Spellcheck.adb Albert Bachmann
2005-04-28 0:41 ` Spellcheck.adb Matthew Heaney
2005-04-28 21:20 ` Spellcheck.adb Simon Wright
2005-04-29 10:05 ` Spellcheck.adb Albert Bachmann
2005-04-29 12:35 ` Spellcheck.adb Matthew Heaney
2005-04-26 21:21 ` Spellcheck.adb Albert Bachmann
2005-04-26 22:04 ` Spellcheck.adb David Sauvage
2005-04-26 20:36 ` [Shootout] Spellcheck.adb Dmitry A. Kazakov
2005-04-26 21:50 ` David Sauvage
2005-04-27 8:40 ` 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