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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b7dc7082d345b1e1 X-Google-Attributes: gid103376,public From: Ray Blaak Subject: Re: package dependence question Date: 2000/05/29 Message-ID: #1/1 X-Deja-AN: 628778170 Sender: blaak@LANGLEY References: <8gt19i$1cm8@r02n01.cac.psu.edu> <393296FB.78AA031D@acm.org> X-Complaints-To: news@bctel.net X-Trace: news.bc.tac.net 959638304 209.53.149.68 (Mon, 29 May 2000 15:11:44 PDT) Organization: The Transcend NNTP-Posting-Date: Mon, 29 May 2000 15:11:44 PDT Newsgroups: comp.lang.ada Date: 2000-05-29T00:00:00+00:00 List-Id: Jeff Carter writes: > Carl Banks wrote: > > So let's say that a particular tree has a different type of node at > > each level. For example, type A is the root of the tree. Its > > branches are of type B. B's branches are of type C, and so on. > > Then this isn't really a tree; it's a hierarchy. Trees have the same > type everywhere a value is stored. Hierarchies are shaped like trees, > but are used differently. I disagree. A tree is simply a directed graph without cycles. There is no requirement that all nodes must be of the same type. In particular, a hierarchy is a tree. However, in an OO implementation of a tree, all nodes will usually be of a common type so that one can specify parent/child relationships in one place. There can certainly be more specialized types for different kinds of nodes. E.g. type TreeNode is tagged record end record; -- common stuff for all nodes, especially knowledge of the parent, child -- containers, etc. function ParentOf(n : TreeNode) : TreeNode; function ChildCount(n : TreeNode) : Natural; function ChildAt(n : TreeNode; index : Natural) : TreeNode; procedure InsertChild(child : in out TreeNode; intoParent : in out TreeNode); -- root node specialization type A is new TreeNode with ... end record; type B is new TreeNode with ... end record; -- leaf nodes? type C is new TreeNode with ... end record; In this case the nodes are simultaneously of the same type (i.e. TreeNode) and yet are different types (A, B, C, ...). -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, blaak@infomatch.com The Rhythm has my soul.