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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8e7ac81a215f128c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!news-2.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Using Red-Black Trees Date: Thu, 18 Nov 2010 11:47:03 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <2419e829-6f45-4075-9005-b9876beb8aaa@r6g2000vbf.googlegroups.com> <46306fd9-21dc-40df-88e7-fc7e568399a4@k11g2000vbf.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323584-1932990948-1290077223=:32645" X-Trace: tigger.scc.uni-weimar.de 1290070163 6295 141.54.178.228 (18 Nov 2010 08:49:23 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Thu, 18 Nov 2010 08:49:23 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Xref: g2news1.google.com comp.lang.ada:15575 Date: 2010-11-18T11:47:03+01:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323584-1932990948-1290077223=:32645 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT On Thu, 18 Nov 2010, Yannick Duch�ne (Hibou57) wrote: > Formally speaking, you do not have multiple > implementations of a single specification. The closest thing actually is > generic package. But that is not easy to do with generics: you will have to > give the generic instance all of its custom implementation via generic > parameters (methods and others). Why is that a big deal? The instance of a polymorphic data structure must somehow be told which operations to use, anyway. Here is, how it should look like (not checked by a compiler). ----------- The specification: generic procedure Insert(Container: in out Store; Key: Key_Type; Item: Payload; Did_Overwrite: out Boolean) procedure Lookup(Container: Store; Key: Key_Type; Item: out Payload; Found: out Boolean); procedure Delete(Container: in out Store; Key: Key_Type; Found: out Boolean); package Do_Something is ... end Do_Something; ----------- Two possible instantiations: package Do_Something_Simple is new Do_Something(Linked_List.Insert, Linked_List.Lookup, Linked_List.Delete); -- use a linked list as the internal data struture -- constant time insert, linear time lookup and delete package Do_Something_Fast is new Do_Something(AVL.Insert, AVL.Lookup, AVL.Delete); -- use an AVL tree, as the internal data structure -- logarithmic time for all of insert, lookup and delete To me, it seems that generics are quite good for eactly that purpose ... Stefan -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------ --8323584-1932990948-1290077223=:32645--