comp.lang.ada
 help / color / mirror / Atom feed
* generic binary tree in ada 83
@ 1998-04-28  0:00 karen westcott
  1998-04-28  0:00 ` Matthew Heaney
  1998-04-28  0:00 ` Michael F Brenner
  0 siblings, 2 replies; 5+ messages in thread
From: karen westcott @ 1998-04-28  0:00 UTC (permalink / raw)



Could you please help me with writting a binary tree that allows generic
data.  I have got one to work that hold a single character, but can't
get modify it to work with generics.  BTW, I am writting in ADA 83 NOT
95.

Any help will be grateful.
Thanks,
	Chris.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generic binary tree in ada 83
  1998-04-28  0:00 generic binary tree in ada 83 karen westcott
  1998-04-28  0:00 ` Matthew Heaney
@ 1998-04-28  0:00 ` Michael F Brenner
  1998-04-28  0:00   ` Robert Dewar
  1998-04-29  0:00   ` Pascal Obry
  1 sibling, 2 replies; 5+ messages in thread
From: Michael F Brenner @ 1998-04-28  0:00 UTC (permalink / raw)



   > I have it working on a single character, but cannot get
   > it to work on generic data.

Just add the following lines on top of your package that implements
the Tree data structure on type character:

    generic
        type character is private;

and it will work on generic data. To instantiate it, use the following
code:
      package tree_of_limbs is new character_tree (character => limbs);

Then it will work on TYPE LIMBS exactly as it worked on type character.

The operational thing here, is that you already have it working on 
a single character. If you did not, then you could not re-use the
code, since the code does not work. But since you have the code
working on one type, it is often trivial to re-use it on other types
in the Ada programming lanaguage.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generic binary tree in ada 83
  1998-04-28  0:00 generic binary tree in ada 83 karen westcott
@ 1998-04-28  0:00 ` Matthew Heaney
  1998-04-28  0:00 ` Michael F Brenner
  1 sibling, 0 replies; 5+ messages in thread
From: Matthew Heaney @ 1998-04-28  0:00 UTC (permalink / raw)



In article <35461333.6DFB@westcott.force9.co.uk>, karen westcott
<karen@westcott.force9.co.uk> wrote:

Could you please help me with writting a binary tree that allows generic
data.  I have got one to work that hold a single character, but can't
get modify it to work with generics.  BTW, I am writting in ADA 83 NOT
95.

Code for this is documented in Grady Booch's data structures book (which
was Ada 83).




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generic binary tree in ada 83
  1998-04-28  0:00 ` Michael F Brenner
@ 1998-04-28  0:00   ` Robert Dewar
  1998-04-29  0:00   ` Pascal Obry
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1998-04-28  0:00 UTC (permalink / raw)



Michael said

<<Just add the following lines on top of your package that implements
the Tree data structure on type character:

    generic
        type character is private;

and it will work on generic data. To instantiate it, use the following
code:
      package tree_of_limbs is new character_tree (character => limbs);

Then it will work on TYPE LIMBS exactly as it worked on type character.
>>


This is almost certainly incorrect advice. It is perhaps deliberately
wrong (people often give answers that are deliberately incomplete when
it sounds likely that the question is of the kind "please help me with
my assignment, I don't feel like doing it myself" (be warned!)

But almost certainly the binary tree implementation will require a
total ordering, which of course the above generic formal does not provide.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generic binary tree in ada 83
  1998-04-28  0:00 ` Michael F Brenner
  1998-04-28  0:00   ` Robert Dewar
@ 1998-04-29  0:00   ` Pascal Obry
  1 sibling, 0 replies; 5+ messages in thread
From: Pascal Obry @ 1998-04-29  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1888 bytes --]


Michael F Brenner a �crit dans le message <6i55q1$nfe@top.mitre.org>...
>   > I have it working on a single character, but cannot get
>   > it to work on generic data.
>
>Just add the following lines on top of your package that implements
>the Tree data structure on type character:
>
>    generic
>        type character is private;
>
>and it will work on generic data. To instantiate it, use the following
>code:
>      package tree_of_limbs is new character_tree (character => limbs);
>
>Then it will work on TYPE LIMBS exactly as it worked on type character.
>
>The operational thing here, is that you already have it working on
>a single character. If you did not, then you could not re-use the
>code, since the code does not work. But since you have the code
>working on one type, it is often trivial to re-use it on other types
>in the Ada programming lanaguage.
>

I'am not really sure this solution will work. How do you know that Karen did
not
make use of the fact that the binary tree contain character ?

Also the use of the predefined type Character here is not elegant at all !

Pascal.

--

--|------------------------------------------------------------
--| Pascal Obry                               Team-Ada Member |
--|                                                           |
--| EDF-DER-IPN-SID- Ing�nierie des Syst�mes d'Informations   |
--|                                                           |
--| Bureau G1-010           e-mail: pascal.obry@der.edfgdf.fr |
--| 1 Av G�n�ral de Gaulle  voice : +33-1-47.65.50.91         |
--| 92141 Clamart CEDEX     fax   : +33-1-47.65.50.07         |
--| FRANCE                                                    |
--|------------------------------------------------------------
--|
--|   http://ourworld.compuserve.com/homepages/pascal_obry
--|
--|   "The best way to travel is by means of imagination"







^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-04-29  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-28  0:00 generic binary tree in ada 83 karen westcott
1998-04-28  0:00 ` Matthew Heaney
1998-04-28  0:00 ` Michael F Brenner
1998-04-28  0:00   ` Robert Dewar
1998-04-29  0:00   ` Pascal Obry

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