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,64fc02e079586f1b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada References: <1114464642.518876.137610@f14g2000cwb.googlegroups.com> <1114548638.851249.246280@f14g2000cwb.googlegroups.com> Subject: Re: Spellcheck.adb Date: Wed, 27 Apr 2005 11:11:06 -0400 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-ID: <426fab8a$0$3712$39cecf19@news.twtelecom.net> Organization: Time-Warner Telecom NNTP-Posting-Date: 27 Apr 2005 15:11:07 GMT NNTP-Posting-Host: a4889c69.news.twtelecom.net X-Trace: DXC=TB?jQ6M1D;eY5dP1cEO1CeC_A=>8kQj6m=_1NR_H?JPm^8fDX^QVaGnJDX5lBYT6=ofQ=W=h4og>k X-Complaints-To: abuse@twtelecom.net Xref: g2news1.google.com comp.lang.ada:10755 Date: 2005-04-27T15:11:07+00:00 List-Id: "Albert Bachmann" 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