comp.lang.ada
 help / color / mirror / Atom feed
* avl tree - booch components
@ 2001-09-07  8:16 Tony Gair
  2001-09-07 11:47 ` Des Walker
                   ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Tony Gair @ 2001-09-07  8:16 UTC (permalink / raw)




I have just had a look at the AVL tree Ada 95 Booch components, and am completely
at a loss to instantiate the AVL tree components. Has anyone here done this,
regards
TG



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

* Re: avl tree - booch components
  2001-09-07  8:16 avl tree - booch components Tony Gair
@ 2001-09-07 11:47 ` Des Walker
  2001-09-07 14:51   ` Simon Wright
  2001-09-09  8:49 ` Dave Parsons
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Des Walker @ 2001-09-07 11:47 UTC (permalink / raw)


Tony Gair wrote:
> 
> I have just had a look at the AVL tree Ada 95 Booch components, and am completely
> at a loss to instantiate the AVL tree components. Has anyone here done this,
> regards
> TG

Hi,

if you downloaded the Booch Components maintained by Simon Wright

http://www.pogner.demon.co.uk/components/bc/download.html

(Hmm, I've just tried downloading the August zip version, but it
wouldn't extract - I'll let Simon know. The May version extracted OK)

There is a test directory included in the download which contains an AVL
Tree test program. I think the tree is instantiated in
avl_test_support.ads.

	Regards
	Des Walker



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

* Re: avl tree - booch components
  2001-09-07 11:47 ` Des Walker
@ 2001-09-07 14:51   ` Simon Wright
  2001-09-07 22:04     ` Ehud Lamm
  2001-09-07 23:59     ` Des Walker
  0 siblings, 2 replies; 36+ messages in thread
From: Simon Wright @ 2001-09-07 14:51 UTC (permalink / raw)


Des Walker <des.walker@amsjv.com> writes:
> Tony Gair wrote:
> > 
> > I have just had a look at the AVL tree Ada 95 Booch components,
> > and am completely at a loss to instantiate the AVL tree
> > components. Has anyone here done this,
> 
> if you downloaded the Booch Components maintained by Simon Wright
> 
> http://www.pogner.demon.co.uk/components/bc/download.html
> 
> (Hmm, I've just tried downloading the August zip version, but it
> wouldn't extract - I'll let Simon know. The May version extracted
> OK)

This is not the first time people have reported problems like this, I
put it down to firewalls and proxy servers myself. Using the same
arrangement as Des I get bad downloads from the above address and also
from the mirror at http://www.adapower.net/booch .

> There is a test directory included in the download which contains an
> AVL Tree test program. I think the tree is instantiated in
> avl_test_support.ads.

These is also now a "case study" which doesn't address instantiating
Trees but does cover Collections. May be some
help. http://www.pogner.demon.co.uk/components/bc/case-study.html



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

* Re: avl tree - booch components
  2001-09-07 14:51   ` Simon Wright
@ 2001-09-07 22:04     ` Ehud Lamm
  2001-09-07 23:59     ` Des Walker
  1 sibling, 0 replies; 36+ messages in thread
From: Ehud Lamm @ 2001-09-07 22:04 UTC (permalink / raw)


Simon Wright <simon.j.wright@amsjv.com> wrote in message
news:x7v7kvboxzq.fsf@galadriel.frlngtn.gecm.com...

> These is also now a "case study" which doesn't address instantiating
> Trees but does cover Collections. May be some
> help. http://www.pogner.demon.co.uk/components/bc/case-study.html

This looks very promising. It is going ot be a real help for those starting
out with the BC library.

Ehud Lamm





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

* Re: avl tree - booch components
  2001-09-07 14:51   ` Simon Wright
  2001-09-07 22:04     ` Ehud Lamm
@ 2001-09-07 23:59     ` Des Walker
  2001-09-08 13:58       ` Tony Gair
  1 sibling, 1 reply; 36+ messages in thread
From: Des Walker @ 2001-09-07 23:59 UTC (permalink / raw)



Simon Wright <simon.j.wright@amsjv.com> wrote in message
news:x7v7kvboxzq.fsf@galadriel.frlngtn.gecm.com...
> Des Walker <des.walker@amsjv.com> writes:
> > (Hmm, I've just tried downloading the August zip version, but it
> > wouldn't extract - I'll let Simon know. The May version extracted
> > OK)
>
> This is not the first time people have reported problems like this, I
> put it down to firewalls and proxy servers myself. Using the same
> arrangement as Des I get bad downloads from the above address and also
> from the mirror at http://www.adapower.net/booch .
>

Just to say I'll have to agrre with what Simon has said, as I managed to
extract the August version correctly on a different setup. So the
problem isn't with the zip file.

    Des Walker






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

* Re: avl tree - booch components
  2001-09-07 23:59     ` Des Walker
@ 2001-09-08 13:58       ` Tony Gair
  0 siblings, 0 replies; 36+ messages in thread
From: Tony Gair @ 2001-09-08 13:58 UTC (permalink / raw)


On Sat, 8 Sep 2001 00:59:20 +0100
"Des Walker" <des.walker@dessy.fsnet.co.uk> wrote:

> 
> Simon Wright <simon.j.wright@amsjv.com> wrote in message
> news:x7v7kvboxzq.fsf@galadriel.frlngtn.gecm.com...
> > Des Walker <des.walker@amsjv.com> writes:
> > > (Hmm, I've just tried downloading the August zip version, but it
> > > wouldn't extract - I'll let Simon know. The May version extracted
> > > OK)
> >
> > This is not the first time people have reported problems like this, I
> > put it down to firewalls and proxy servers myself. Using the same
> > arrangement as Des I get bad downloads from the above address and also
> > from the mirror at http://www.adapower.net/booch .
> >
> 
> Just to say I'll have to agrre with what Simon has said, as I managed to
> extract the August version correctly on a different setup. So the
> problem isn't with the zip file.
> 
>     Des Walker
> 
> 
> 
Thanks guys



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

* Re: avl tree - booch components
  2001-09-07  8:16 avl tree - booch components Tony Gair
  2001-09-07 11:47 ` Des Walker
@ 2001-09-09  8:49 ` Dave Parsons
  2001-09-09 18:27   ` Simon Wright
  2001-09-10 21:52 ` Jeffrey D. Cherry
  2001-09-10 21:53 ` Jeffrey D. Cherry
  3 siblings, 1 reply; 36+ messages in thread
From: Dave Parsons @ 2001-09-09  8:49 UTC (permalink / raw)


On Fri, 7 Sep 2001 08:16:10, Tony Gair <tonygair@nospam.blueyonder.co.uk> wrote:

> 
> 
> I have just had a look at the AVL tree Ada 95 Booch components, and am completely
> at a loss to instantiate the AVL tree components. Has anyone here done this,
> regards
> TG

Yes, I compiled all the tests and demos last weekend.
I had to turn off the style checking though, too many lines too long.

Only queue_tests_concurrent seemed to have a serious problem. It
compiled ok but hung near the end.

All the others ran ok and the results looked ok except for
map_test_concurrent, M10G, M11G, M10S & M11S.

I've never used the Booch Components before on any platform, so I
don't know how this compares with other versions.

Comments anyone?

-- 
Dave
Gnat3.13p for OS/2




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

* Re: avl tree - booch components
  2001-09-09  8:49 ` Dave Parsons
@ 2001-09-09 18:27   ` Simon Wright
  2001-09-09 19:22     ` Simon Wright
                       ` (5 more replies)
  0 siblings, 6 replies; 36+ messages in thread
From: Simon Wright @ 2001-09-09 18:27 UTC (permalink / raw)


dwparsons@t-online.de (Dave Parsons) writes:

> Yes, I compiled all the tests and demos last weekend.  I had to turn
> off the style checking though, too many lines too long.

-gnaty gives errors on 3.13p, I'm used to warnings with 3.14a1. Sorry.
The 'lines too long' are typically the revision control strings, shame
CVS doesn't let you customise what $Id$ gives you ..

> Only queue_tests_concurrent seemed to have a serious problem. It
> compiled ok but hung near the end.

Hmm, on Linux it works as expected when run from the makefile but
locks up when run from the command line: ... stranger & stranger,
actually it works *every other time*. More investigation needed.

> All the others ran ok and the results looked ok except for
> map_test_concurrent, M10G, M11G, M10S & M11S.

This is correct behaviour, I forgot to update that test; this is the diff

--- map_test_concurrent.adb     2001/04/14 08:35:27     1.6
+++ map_test_concurrent.adb     2001/09/09 18:09:38
@@ -340,13 +340,13 @@
     Assertion (MUS."=" (The_US.Map_U_Pu1, Map_U_Pu3),
                "** M09S: Maps are not equal");
   end;
-  Assertion (MBG.Available (The_BG.Map_B_Pu1) = 297,
+  Assertion (MBG.Available (The_BG.Map_B_Pu1) = 97,
              "** M10G: Available space is not correct");
-  Assertion (MBG.Available (The_BG.Map_B_Pu2) = 300,
+  Assertion (MBG.Available (The_BG.Map_B_Pu2) = 100,
              "** M11G: Available space is not correct");
-  Assertion (MBS.Available (The_BS.Map_B_Pu1) = 297,
+  Assertion (MBS.Available (The_BS.Map_B_Pu1) = 97,
              "** M10S: Available space is not correct");
-  Assertion (MBS.Available (The_BS.Map_B_Pu2) = 300,
+  Assertion (MBS.Available (The_BS.Map_B_Pu2) = 100,
              "** M11S: Available space is not correct");
   Put_Line ("Completed map tests");

> I've never used the Booch Components before on any platform, so I
> don't know how this compares with other versions.
> 
> Comments anyone?

Thanks for the report.



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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
@ 2001-09-09 19:22     ` Simon Wright
  2001-09-12  7:48       ` Dave Parsons
  2001-09-09 21:01     ` Dave Parsons
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 36+ messages in thread
From: Simon Wright @ 2001-09-09 19:22 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> dwparsons@t-online.de (Dave Parsons) writes:
[...]
> > Only queue_tests_concurrent seemed to have a serious problem. It
> > compiled ok but hung near the end.
> 
> Hmm, on Linux it works as expected when run from the makefile but
> locks up when run from the command line: ... stranger & stranger,
> actually it works *every other time*. More investigation needed.

Turns out task T1 had select/else when it clearly should have been
select/or.

A stupid mistake, a misleading symptom, I think I need a test engineer
round here :-)



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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
  2001-09-09 19:22     ` Simon Wright
@ 2001-09-09 21:01     ` Dave Parsons
  2001-09-10  6:59     ` Dave Parsons
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 36+ messages in thread
From: Dave Parsons @ 2001-09-09 21:01 UTC (permalink / raw)


On Sun, 9 Sep 2001 18:27:48, Simon Wright <simon@pushface.org> wrote:

> dwparsons@t-online.de (Dave Parsons) writes:
> 
> > Yes, I compiled all the tests and demos last weekend.  I had to turn
> > off the style checking though, too many lines too long.
> 
> -gnaty gives errors on 3.13p, I'm used to warnings with 3.14a1. Sorry.
> The 'lines too long' are typically the revision control strings, shame
> CVS doesn't let you customise what $Id$ gives you ..
> 
> > Only queue_tests_concurrent seemed to have a serious problem. It
> > compiled ok but hung near the end.
> 
> Hmm, on Linux it works as expected when run from the makefile but
> locks up when run from the command line: ... stranger & stranger,
> actually it works *every other time*. More investigation needed.
> 
> > All the others ran ok and the results looked ok except for
> > map_test_concurrent, M10G, M11G, M10S & M11S.
> 
> This is correct behaviour, I forgot to update that test; this is the diff
> 
> --- map_test_concurrent.adb     2001/04/14 08:35:27     1.6
> +++ map_test_concurrent.adb     2001/09/09 18:09:38
> @@ -340,13 +340,13 @@
>      Assertion (MUS."=" (The_US.Map_U_Pu1, Map_U_Pu3),
>                 "** M09S: Maps are not equal");
>    end;
> -  Assertion (MBG.Available (The_BG.Map_B_Pu1) = 297,
> +  Assertion (MBG.Available (The_BG.Map_B_Pu1) = 97,
>               "** M10G: Available space is not correct");
> -  Assertion (MBG.Available (The_BG.Map_B_Pu2) = 300,
> +  Assertion (MBG.Available (The_BG.Map_B_Pu2) = 100,
>               "** M11G: Available space is not correct");
> -  Assertion (MBS.Available (The_BS.Map_B_Pu1) = 297,
> +  Assertion (MBS.Available (The_BS.Map_B_Pu1) = 97,
>               "** M10S: Available space is not correct");
> -  Assertion (MBS.Available (The_BS.Map_B_Pu2) = 300,
> +  Assertion (MBS.Available (The_BS.Map_B_Pu2) = 100,
>               "** M11S: Available space is not correct");
>    Put_Line ("Completed map tests");
> 
> > I've never used the Booch Components before on any platform, so I
> > don't know how this compares with other versions.
> > 
> > Comments anyone?
> 
> Thanks for the report.

Ok, good, thanks to you also for confirming that this version is working
resonably well.

I'll update that test and see how it goes.

-- 
Dave






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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
  2001-09-09 19:22     ` Simon Wright
  2001-09-09 21:01     ` Dave Parsons
@ 2001-09-10  6:59     ` Dave Parsons
  2001-09-26 14:00       ` Tony Gair
  2001-09-10  6:59     ` Dave Parsons
                       ` (2 subsequent siblings)
  5 siblings, 1 reply; 36+ messages in thread
From: Dave Parsons @ 2001-09-10  6:59 UTC (permalink / raw)


On Sun, 9 Sep 2001 18:27:48, Simon Wright <simon@pushface.org> wrote:

> dwparsons@t-online.de (Dave Parsons) writes:
 
> > Only queue_tests_concurrent seemed to have a serious problem. It
> > compiled ok but hung near the end.
> 
> Hmm, on Linux it works as expected when run from the makefile but
> locks up when run from the command line: ... stranger & stranger,
> actually it works *every other time*. More investigation needed.
> 

If you find anything, I would be pleased to try it here with this
OS/2 version. I'm still at the testing phase at the moment and
looking to get confidence that it is working as well as can be
expected before releasing it.

-- 
Dave




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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
                       ` (2 preceding siblings ...)
  2001-09-10  6:59     ` Dave Parsons
@ 2001-09-10  6:59     ` Dave Parsons
  2001-09-10 16:21     ` Stephen Leake
  2002-02-25 14:04     ` Dave Parsons
  5 siblings, 0 replies; 36+ messages in thread
From: Dave Parsons @ 2001-09-10  6:59 UTC (permalink / raw)


On Sun, 9 Sep 2001 18:27:48, Simon Wright <simon@pushface.org> wrote:

> dwparsons@t-online.de (Dave Parsons) writes:

> > All the others ran ok and the results looked ok except for
> > map_test_concurrent, M10G, M11G, M10S & M11S.
> 
> This is correct behaviour, I forgot to update that test; this is the diff
> 
> --- map_test_concurrent.adb     2001/04/14 08:35:27     1.6
> +++ map_test_concurrent.adb     2001/09/09 18:09:38
> @@ -340,13 +340,13 @@

Yep, that fixed it - just leaves queue_test_concurrent now.

Thanks,
-- 
Dave



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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
                       ` (3 preceding siblings ...)
  2001-09-10  6:59     ` Dave Parsons
@ 2001-09-10 16:21     ` Stephen Leake
  2001-09-10 19:18       ` Pascal Obry
  2001-09-11  5:53       ` Simon Wright
  2002-02-25 14:04     ` Dave Parsons
  5 siblings, 2 replies; 36+ messages in thread
From: Stephen Leake @ 2001-09-10 16:21 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> dwparsons@t-online.de (Dave Parsons) writes:
> 
> > Yes, I compiled all the tests and demos last weekend.  I had to turn
> > off the style checking though, too many lines too long.
> 
> -gnaty gives errors on 3.13p, I'm used to warnings with 3.14a1. Sorry.
> The 'lines too long' are typically the revision control strings, shame
> CVS doesn't let you customise what $Id$ gives you ..

Hmm. I agree it would be nice if you could have both CVS $Id$ and no
warnings from the GNAT style check. However, given a choice between
the two, I'll take the no warnings.

Do you ever actually read the output of CVS $Id$ ? What is it actually
used for?

Ignoring warnings in general is very bad practice, and it's too easy
to go from "well, _this_ warning is ok" to "I checked all the warnings
last week, I'll ignore them this time" to "just ignore the warnings".

-- 
-- Stephe



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

* Re: avl tree - booch components
  2001-09-10 16:21     ` Stephen Leake
@ 2001-09-10 19:18       ` Pascal Obry
  2001-09-11  5:45         ` Simon Wright
  2001-09-11  5:53       ` Simon Wright
  1 sibling, 1 reply; 36+ messages in thread
From: Pascal Obry @ 2001-09-10 19:18 UTC (permalink / raw)



Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Simon Wright <simon@pushface.org> writes:
> 
> > dwparsons@t-online.de (Dave Parsons) writes:
> > 
> > > Yes, I compiled all the tests and demos last weekend.  I had to turn
> > > off the style checking though, too many lines too long.
> > 
> > -gnaty gives errors on 3.13p, I'm used to warnings with 3.14a1. Sorry.
> > The 'lines too long' are typically the revision control strings, shame
> > CVS doesn't let you customise what $Id$ gives you ..
> 
> Hmm. I agree it would be nice if you could have both CVS $Id$ and no
> warnings from the GNAT style check. However, given a choice between
> the two, I'll take the no warnings.

I don't have the info at hand but I think that there is a pragma to
enable/disable the syle checks. Just put that arround the CVS $Id$
line. Should fix the problem...

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



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

* Re: avl tree - booch components
  2001-09-07  8:16 avl tree - booch components Tony Gair
  2001-09-07 11:47 ` Des Walker
  2001-09-09  8:49 ` Dave Parsons
@ 2001-09-10 21:52 ` Jeffrey D. Cherry
  2001-09-10 21:53 ` Jeffrey D. Cherry
  3 siblings, 0 replies; 36+ messages in thread
From: Jeffrey D. Cherry @ 2001-09-10 21:52 UTC (permalink / raw)


I once created the following package and driver program for a colleague.
It was derived from a much larger project where we used an AVL tree as 
part of a symbol table for a FORTRAN parser.  It compiles with GNAT v3.13p
under Windows 2000 and the August 19, 2001 version of the Booch components.
Though comments are somewhat sparse, there is some explanation regarding
instantiating the AVL tree.  Hope this helps.
-- 
Regards,
Jeffrey D. Cherry
Senior IV&V Analyst
Logicon Operations and Services
Logicon Inc.
a Northrop Grumman company



-- This is a simple package to store "keywords" and an associated data
-- item as an abstract data object.  We'll refer to this abstract data
-- object simply as the keyword container.

package Keyword_Manager is

   -- This is a dummy type so we can associate some kind of data with
   -- a key field.  The dummy type can, of course, be very complex if
   -- it is appropriate for the problem.  It could also be a generic
   -- parameter.  For that matter, the "key" type (strings in this
   -- example) could be a generic parameter as well.  I won't do that
   -- here since too many levels of generic instantiations will detract
   -- from what I'm trying to show.
   type ID_Type is (Unknown_ID, Known_ID, Another_ID, Yet_Another_ID);

-- Clear the keyword container of all (keyword,ID) pairs so that we
-- have an empty keyword container.
procedure Clear_Keywords;

-- Return true if the keyword container is empty and return false
-- if there are one or more (keyword,ID) pairs in the keyword container.
function Is_Empty return boolean;

-- Return the number of (keyword,ID) pairs in the keyword container.
function Number return natural;

-- Insert a keyword and its associated data into the keyword container.
-- If the keyword already exists, then the ignore the data.  (Normally
-- we would want to signal some kind of fault - perhaps via an exception.
-- However, we don't want to focus on error processing in this example.)
procedure Insert(
   Keyword : in string;
   ID      : in ID_Type);

-- Return true if the given keyword exists in the keyword container and
-- return false if it does not exist in the keyword container.
function Exists(Keyword : in string) return boolean;

-- Return the ID associated with the given keyword.  If the keyword
-- doesn't exist in the keyword container, then Unknown_ID is returned.
-- (Again, this should probably raise an exception but we're not
-- focusing on error processing.)
function Identify(Keyword : in string) return ID_Type;

-- Write the contents of the keyword container to standard output.
-- Normally we would want to make this ability much more flexible,
-- but we make another concession for a simple example.
procedure Put_Keywords;

end Keyword_Manager;


with Ada.Strings.Unbounded;             use Ada.Strings.Unbounded;
with Ada.Strings.Maps.Constants;

with BC.Containers.Trees.AVL.Print;
with BC.Support.Unmanaged_Storage;

package body Keyword_Manager is

   -- A node for the keyword table.  This is the information stored in
   -- the AVL tree.  We use unbounded strings since we don't know the
   -- length of our key strings.  If we did, we could use the bounded
   -- form from Ada.Strings.Bounded.
   type Keyword_Node is
      record
         Keyword : Unbounded_String := Null_Unbounded_String;
         ID      : ID_Type          := Unknown_ID;
      end record;

   -- Eventually, we'll need some kind of storage management for the
   -- Keyword_Node structures and the tree that stores the data.  For
   -- this example, we don't care too much about storage issues, so we'll
   -- use the default unmanaged storage provided by the Booch components.
   subtype Tree_Storage_Pool is BC.Support.Unmanaged_Storage.Pool;
   Tree_Storage : Tree_Storage_Pool;

-- Equality function used to identify equivalent nodes in the AVL tree.
-- Notice that the test is case insensative.
function Same_Keyword(Left, Right : in Keyword_Node) return boolean is
   use Ada.Strings.Maps.Constants;
begin -- Same_Keyword
   return Translate(Left.Keyword, Lower_Case_Map) =
         Translate(Right.Keyword, Lower_Case_Map);
end Same_Keyword;

-- Ordering function used to order nodes in the AVL tree.  Notice that
-- the nodes are in reverse alphabetical order and are case insensative.
function Is_Before(Left, Right : in Keyword_Node) return boolean is
   use Ada.Strings.Maps.Constants;
begin -- Is_Before
   return Translate(Left.Keyword, Lower_Case_Map) >
         Translate(Right.Keyword, Lower_Case_Map);
end Is_Before;


-- First create an abstract container that can hold our Keyword_Nodes and
-- can test for two identical Keyword_Nodes.
package Keyword_Containers is
   new BC.Containers(Item => Keyword_Node, "=" => Same_Keyword);

-- Since an abstract tree is just another form of an abstract container,
-- we create an abstract container that uses an abstract tree structure.
-- No new information is required to be given to the abstract tree
-- container and so this is just a simple instantiation built off our
-- previous container.
package Keyword_Container_Trees is new Keyword_Containers.Trees;

-- Now we must define a substantial form for the abstract tree container.
-- This is where we decide to use an AVL form of a tree rather than some
-- other form (e.g., binary or multiway).  Since a tree stores data in
-- an ordered fashion, we must tell the AVL tree how to order our data.
-- This is done with the ordering function we defined above (function
-- Is_Before).  This will also be our concrete package that must deal
-- with both allocation and deallocation of memory resources for the
-- tree nodes.
package Keyword_Trees is
   new Keyword_Container_Trees.AVL(
      "<"             => Is_Before,
      Storage_Manager => Tree_Storage_Pool,
      Storage         => Tree_Storage);

   -- Okay, we can now define an object that will contain our Keyword_Nodes.
   -- It is a container that uses an AVL tree structure to hold the data.
   Keyword_Table : Keyword_Trees.AVL_Tree;


procedure Clear_Keywords is
begin -- Clear_Keywords
   Keyword_Trees.Clear(Keyword_Table);
end Clear_Keywords;


function Is_Empty return boolean is
begin -- Is_Empty
   return Keyword_Trees.Is_Null(Keyword_Table);
end Is_Empty;


function Number return natural is
begin -- Number
   return Keyword_Trees.Extent(Keyword_Table);
end Number;


procedure Insert(
   Keyword : in string;
   ID      : in ID_Type) is

   Keyword_Added : boolean;

begin -- Insert
   Keyword_Trees.Insert(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), ID),
         Keyword_Added);
end Insert;


function Exists(Keyword : in string) return boolean is
begin -- Exists
   return Keyword_Trees.Is_Member(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), Unknown_ID));
end Exists;


function Identify(Keyword : in string) return ID_Type is

   ID    : ID_Type := Unknown_ID;
   Found : boolean;

procedure Get_ID(Item : in out Keyword_Node) is
begin -- Get_ID
   ID := Item.ID;
end Get_ID;

procedure Find_Node is new Keyword_Trees.Access_Actual_Item(Get_ID);

begin -- Identify
   Find_Node(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), Unknown_ID),
         Found);
   return ID;
end Identify;


procedure Put_Keywords is

function Keyword_Image(Item : in Keyword_Node) return string is
begin -- Keyword_Image
   return "(" & To_String(Item.Keyword) & "," & ID_Type'image(Item.ID) & ")";
end Keyword_Image;

procedure Put_Tree is new Keyword_Trees.Print(Keyword_Image);

begin -- Put_Keywords
   Put_Tree(Keyword_Table);
end Put_Keywords;

end Keyword_Manager;


with Ada.Command_Line;
with Ada.Text_IO;                       use Ada.Text_IO;
with Ada.Strings.Fixed;                 use Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants;        use Ada.Strings.Maps.Constants;

with Keyword_Manager;                   use Keyword_Manager;

procedure KM_Test is

   Keyword_File : File_Type;
   Buffer       : string(1..1024);
   Last         : natural;
   i, j         : natural;
   ID           : ID_Type := Known_ID;

begin -- KM_Test
   if Ada.Command_Line.Argument_Count = 1 then
      Open(Keyword_File, In_File, Ada.Command_Line.Argument(1));
      Clear_Keywords;

      while not End_Of_File(Keyword_File) loop
         Get_Line(Keyword_File, Buffer, Last);
         if Last in Buffer'range then
            i := Buffer'first;
            loop
               Find_Token(Buffer(i..Last), Letter_Set, Ada.Strings.Inside, i,
j);
               exit when j = 0;
               Insert(Buffer(i..j), ID);
               if ID = Yet_Another_ID then
                  ID := Known_ID;
               else
                  ID := ID_Type'succ(ID);
               end if;
               i := natural'succ(j);
               exit when i > Last;
            end loop;
         end if;
      end loop;
      Close(Keyword_File);

      if Is_Empty then
         Put_Line("Keyword container is empty.");

      else
         Put_Line("There are" & natural'image(Number) &
               " items in the keyword container.");
         New_Line(2);
         Put_Line("Contents of the keyword container are as follows:");
         Put_Keywords;
         New_Line(4);

         loop
            Put("Enter keyword to look up: ");
            Get_Line(Buffer, Last);
            exit when Last not in Buffer'range;
            if Exists(Buffer(1..Last)) then
               Put_Line("""" & Buffer(1..Last) &
                     """ is in the keyword container and its ID is " &
                     ID_Type'image(Identify(Buffer(1..Last))) & ".");
            else
               Put_Line("""" & Buffer(1..Last) &
                     """ does not exist in the keyword container!");
            end if;
         end loop;
      end if;
   end if;
end KM_Test;



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

* Re: avl tree - booch components
  2001-09-07  8:16 avl tree - booch components Tony Gair
                   ` (2 preceding siblings ...)
  2001-09-10 21:52 ` Jeffrey D. Cherry
@ 2001-09-10 21:53 ` Jeffrey D. Cherry
  3 siblings, 0 replies; 36+ messages in thread
From: Jeffrey D. Cherry @ 2001-09-10 21:53 UTC (permalink / raw)


I once created the following package and driver program for a colleague.
It was derived from a much larger project where we used an AVL tree as 
part of a symbol table for a FORTRAN parser.  It compiles with GNAT v3.13p
under Windows 2000 and the August 19, 2001 version of the Booch components.
Though comments are somewhat sparse, there is some explanation regarding
instantiating the AVL tree.  Hope this helps.
-- 
Regards,
Jeffrey D. Cherry
Senior IV&V Analyst
Logicon Operations and Services
Logicon Inc.
a Northrop Grumman company



-- This is a simple package to store "keywords" and an associated data
-- item as an abstract data object.  We'll refer to this abstract data
-- object simply as the keyword container.

package Keyword_Manager is

   -- This is a dummy type so we can associate some kind of data with
   -- a key field.  The dummy type can, of course, be very complex if
   -- it is appropriate for the problem.  It could also be a generic
   -- parameter.  For that matter, the "key" type (strings in this
   -- example) could be a generic parameter as well.  I won't do that
   -- here since too many levels of generic instantiations will detract
   -- from what I'm trying to show.
   type ID_Type is (Unknown_ID, Known_ID, Another_ID, Yet_Another_ID);

-- Clear the keyword container of all (keyword,ID) pairs so that we
-- have an empty keyword container.
procedure Clear_Keywords;

-- Return true if the keyword container is empty and return false
-- if there are one or more (keyword,ID) pairs in the keyword container.
function Is_Empty return boolean;

-- Return the number of (keyword,ID) pairs in the keyword container.
function Number return natural;

-- Insert a keyword and its associated data into the keyword container.
-- If the keyword already exists, then the ignore the data.  (Normally
-- we would want to signal some kind of fault - perhaps via an exception.
-- However, we don't want to focus on error processing in this example.)
procedure Insert(
   Keyword : in string;
   ID      : in ID_Type);

-- Return true if the given keyword exists in the keyword container and
-- return false if it does not exist in the keyword container.
function Exists(Keyword : in string) return boolean;

-- Return the ID associated with the given keyword.  If the keyword
-- doesn't exist in the keyword container, then Unknown_ID is returned.
-- (Again, this should probably raise an exception but we're not
-- focusing on error processing.)
function Identify(Keyword : in string) return ID_Type;

-- Write the contents of the keyword container to standard output.
-- Normally we would want to make this ability much more flexible,
-- but we make another concession for a simple example.
procedure Put_Keywords;

end Keyword_Manager;


with Ada.Strings.Unbounded;             use Ada.Strings.Unbounded;
with Ada.Strings.Maps.Constants;

with BC.Containers.Trees.AVL.Print;
with BC.Support.Unmanaged_Storage;

package body Keyword_Manager is

   -- A node for the keyword table.  This is the information stored in
   -- the AVL tree.  We use unbounded strings since we don't know the
   -- length of our key strings.  If we did, we could use the bounded
   -- form from Ada.Strings.Bounded.
   type Keyword_Node is
      record
         Keyword : Unbounded_String := Null_Unbounded_String;
         ID      : ID_Type          := Unknown_ID;
      end record;

   -- Eventually, we'll need some kind of storage management for the
   -- Keyword_Node structures and the tree that stores the data.  For
   -- this example, we don't care too much about storage issues, so we'll
   -- use the default unmanaged storage provided by the Booch components.
   subtype Tree_Storage_Pool is BC.Support.Unmanaged_Storage.Pool;
   Tree_Storage : Tree_Storage_Pool;

-- Equality function used to identify equivalent nodes in the AVL tree.
-- Notice that the test is case insensative.
function Same_Keyword(Left, Right : in Keyword_Node) return boolean is
   use Ada.Strings.Maps.Constants;
begin -- Same_Keyword
   return Translate(Left.Keyword, Lower_Case_Map) =
         Translate(Right.Keyword, Lower_Case_Map);
end Same_Keyword;

-- Ordering function used to order nodes in the AVL tree.  Notice that
-- the nodes are in reverse alphabetical order and are case insensative.
function Is_Before(Left, Right : in Keyword_Node) return boolean is
   use Ada.Strings.Maps.Constants;
begin -- Is_Before
   return Translate(Left.Keyword, Lower_Case_Map) >
         Translate(Right.Keyword, Lower_Case_Map);
end Is_Before;


-- First create an abstract container that can hold our Keyword_Nodes and
-- can test for two identical Keyword_Nodes.
package Keyword_Containers is
   new BC.Containers(Item => Keyword_Node, "=" => Same_Keyword);

-- Since an abstract tree is just another form of an abstract container,
-- we create an abstract container that uses an abstract tree structure.
-- No new information is required to be given to the abstract tree
-- container and so this is just a simple instantiation built off our
-- previous container.
package Keyword_Container_Trees is new Keyword_Containers.Trees;

-- Now we must define a substantial form for the abstract tree container.
-- This is where we decide to use an AVL form of a tree rather than some
-- other form (e.g., binary or multiway).  Since a tree stores data in
-- an ordered fashion, we must tell the AVL tree how to order our data.
-- This is done with the ordering function we defined above (function
-- Is_Before).  This will also be our concrete package that must deal
-- with both allocation and deallocation of memory resources for the
-- tree nodes.
package Keyword_Trees is
   new Keyword_Container_Trees.AVL(
      "<"             => Is_Before,
      Storage_Manager => Tree_Storage_Pool,
      Storage         => Tree_Storage);

   -- Okay, we can now define an object that will contain our Keyword_Nodes.
   -- It is a container that uses an AVL tree structure to hold the data.
   Keyword_Table : Keyword_Trees.AVL_Tree;


procedure Clear_Keywords is
begin -- Clear_Keywords
   Keyword_Trees.Clear(Keyword_Table);
end Clear_Keywords;


function Is_Empty return boolean is
begin -- Is_Empty
   return Keyword_Trees.Is_Null(Keyword_Table);
end Is_Empty;


function Number return natural is
begin -- Number
   return Keyword_Trees.Extent(Keyword_Table);
end Number;


procedure Insert(
   Keyword : in string;
   ID      : in ID_Type) is

   Keyword_Added : boolean;

begin -- Insert
   Keyword_Trees.Insert(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), ID),
         Keyword_Added);
end Insert;


function Exists(Keyword : in string) return boolean is
begin -- Exists
   return Keyword_Trees.Is_Member(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), Unknown_ID));
end Exists;


function Identify(Keyword : in string) return ID_Type is

   ID    : ID_Type := Unknown_ID;
   Found : boolean;

procedure Get_ID(Item : in out Keyword_Node) is
begin -- Get_ID
   ID := Item.ID;
end Get_ID;

procedure Find_Node is new Keyword_Trees.Access_Actual_Item(Get_ID);

begin -- Identify
   Find_Node(Keyword_Table,
         Keyword_Node'(To_Unbounded_String(Keyword), Unknown_ID),
         Found);
   return ID;
end Identify;


procedure Put_Keywords is

function Keyword_Image(Item : in Keyword_Node) return string is
begin -- Keyword_Image
   return "(" & To_String(Item.Keyword) & "," & ID_Type'image(Item.ID) & ")";
end Keyword_Image;

procedure Put_Tree is new Keyword_Trees.Print(Keyword_Image);

begin -- Put_Keywords
   Put_Tree(Keyword_Table);
end Put_Keywords;

end Keyword_Manager;


with Ada.Command_Line;
with Ada.Text_IO;                       use Ada.Text_IO;
with Ada.Strings.Fixed;                 use Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants;        use Ada.Strings.Maps.Constants;

with Keyword_Manager;                   use Keyword_Manager;

procedure KM_Test is

   Keyword_File : File_Type;
   Buffer       : string(1..1024);
   Last         : natural;
   i, j         : natural;
   ID           : ID_Type := Known_ID;

begin -- KM_Test
   if Ada.Command_Line.Argument_Count = 1 then
      Open(Keyword_File, In_File, Ada.Command_Line.Argument(1));
      Clear_Keywords;

      while not End_Of_File(Keyword_File) loop
         Get_Line(Keyword_File, Buffer, Last);
         if Last in Buffer'range then
            i := Buffer'first;
            loop
               Find_Token(Buffer(i..Last), Letter_Set, Ada.Strings.Inside, i,
j);
               exit when j = 0;
               Insert(Buffer(i..j), ID);
               if ID = Yet_Another_ID then
                  ID := Known_ID;
               else
                  ID := ID_Type'succ(ID);
               end if;
               i := natural'succ(j);
               exit when i > Last;
            end loop;
         end if;
      end loop;
      Close(Keyword_File);

      if Is_Empty then
         Put_Line("Keyword container is empty.");

      else
         Put_Line("There are" & natural'image(Number) &
               " items in the keyword container.");
         New_Line(2);
         Put_Line("Contents of the keyword container are as follows:");
         Put_Keywords;
         New_Line(4);

         loop
            Put("Enter keyword to look up: ");
            Get_Line(Buffer, Last);
            exit when Last not in Buffer'range;
            if Exists(Buffer(1..Last)) then
               Put_Line("""" & Buffer(1..Last) &
                     """ is in the keyword container and its ID is " &
                     ID_Type'image(Identify(Buffer(1..Last))) & ".");
            else
               Put_Line("""" & Buffer(1..Last) &
                     """ does not exist in the keyword container!");
            end if;
         end loop;
      end if;
   end if;
end KM_Test;



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

* Re: avl tree - booch components
  2001-09-10 19:18       ` Pascal Obry
@ 2001-09-11  5:45         ` Simon Wright
  2001-09-12  9:02           ` David C. Hoos, Sr.
  0 siblings, 1 reply; 36+ messages in thread
From: Simon Wright @ 2001-09-11  5:45 UTC (permalink / raw)


Pascal Obry <p.obry@wanadoo.fr> writes:

> I don't have the info at hand but I think that there is a pragma to
> enable/disable the syle checks. Just put that arround the CVS $Id$
> line. Should fix the problem...

Nor do I, but when I tried it I got the strong impression that you can
turn checks On but not Off.



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

* Re: avl tree - booch components
  2001-09-10 16:21     ` Stephen Leake
  2001-09-10 19:18       ` Pascal Obry
@ 2001-09-11  5:53       ` Simon Wright
  2001-09-12  9:10         ` David C. Hoos, Sr.
  1 sibling, 1 reply; 36+ messages in thread
From: Simon Wright @ 2001-09-11  5:53 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Hmm. I agree it would be nice if you could have both CVS $Id$ and no
> warnings from the GNAT style check. However, given a choice between
> the two, I'll take the no warnings.

I will adopt a style like

--  $RCSfile: bc-containers-collections-ordered-bounded.ads,v $
--  $Revision: 1.5 $
--  $Date: 2001/09/11 05:29:27 $
--  $Author: simon $

(I don't _think_ the RCSfile is likely to break the limit)

> Do you ever actually read the output of CVS $Id$ ? What is it actually
> used for?

At a pinch I suppose RCSfile and Revision would be the minimum, but I
find the date very useful too especially when not connected to the
repository.

What file is this? what version? when did it last change? who changed
it? are all important. The last particularly so given multiple
users. I know it's all available from the repository (cvs status; cvs
log) but still ..

> Ignoring warnings in general is very bad practice, and it's too easy
> to go from "well, _this_ warning is ok" to "I checked all the warnings
> last week, I'll ignore them this time" to "just ignore the warnings".

How very true!



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

* Re: avl tree - booch components
  2001-09-09 19:22     ` Simon Wright
@ 2001-09-12  7:48       ` Dave Parsons
  0 siblings, 0 replies; 36+ messages in thread
From: Dave Parsons @ 2001-09-12  7:48 UTC (permalink / raw)


On Sun, 9 Sep 2001 19:22:06, Simon Wright <simon@pushface.org> wrote:

> Simon Wright <simon@pushface.org> writes:
> 
> > dwparsons@t-online.de (Dave Parsons) writes:
> [...]
> > > Only queue_tests_concurrent seemed to have a serious problem. It
> > > compiled ok but hung near the end.
> > 
> > Hmm, on Linux it works as expected when run from the makefile but
> > locks up when run from the command line: ... stranger & stranger,
> > actually it works *every other time*. More investigation needed.
> 
> Turns out task T1 had select/else when it clearly should have been
> select/or.
> 

Yes, it works fine here now.

Thanks

-- 
Dave



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

* Re: avl tree - booch components
  2001-09-11  5:45         ` Simon Wright
@ 2001-09-12  9:02           ` David C. Hoos, Sr.
  2001-09-12 10:37             ` Florian Weimer
  0 siblings, 1 reply; 36+ messages in thread
From: David C. Hoos, Sr. @ 2001-09-12  9:02 UTC (permalink / raw)
  To: comp.lang.ada; +Cc: simon

Here is the relevant information:

pragma Style_Checks
Syntax:
pragma Style_Checks (string_LITERAL | ALL_CHECKS | On | Off [, LOCAL_NAME]);

This pragma is used in conjunction with compiler switches to control the built
in style checking provided by GNAT. The compiler switches, if set provide an
initial setting for the switches, and this pragma may be used to modify these
settings, or the settings may be provided entirely by the use of the pragma.
This pragma can be used anywhere that a pragma is legal, including use as a
configuration pragma (including use in the `gnat.adc' file). The form with a
string literal specifies which style options are to be activated. These are
additive, so they apply in addition to any previously set style check options.
The codes for the options are the same as those used in the -gnaty switch on
the gcc or gnatmake line. For example the following two methods can be used to
enable layout checking:
pragma Style_Checks ("l");
gcc -c -gnatyl ...

The form ALL_CHECKS activates all checks (its use is equivalent to the use of
the gnaty switch with no options. See GNAT User's Guide for details. The forms
with Off and On can be used to temporarily disable style checks as shown in
the following example:
pragma Style_Checks ("k"); -- requires keywords in lower case
pragma Style_Checks (Off); -- turn off style checks
NULL;                      -- this will not generate an error message
pragma Style_Checks (On);  -- turn style checks back on
NULL;                      -- this will generate an error message

Finally the two argument form is allowed only if the first argument is On or
Off. The effect is to turn of semantic style checks for the specified entity,
as shown in the following example:
pragma Style_Checks ("r"); -- require consistency of identifier casing
Arg : Integer;
Rf1 : Integer := ARG;      -- incrrect, wrong case
pragma Style_Checks (Off, Arg);
Rf2 : Integer := ARG;      -- OK, no error


----- Original Message -----
From: "Simon Wright" <simon@pushface.org>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: September 11, 2001 12:45 AM
Subject: Re: avl tree - booch components


Pascal Obry <p.obry@wanadoo.fr> writes:

> I don't have the info at hand but I think that there is a pragma to
> enable/disable the syle checks. Just put that arround the CVS $Id$
> line. Should fix the problem...

Nor do I, but when I tried it I got the strong impression that you can
turn checks On but not Off.
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada






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

* Re: avl tree - booch components
  2001-09-11  5:53       ` Simon Wright
@ 2001-09-12  9:10         ` David C. Hoos, Sr.
  2001-09-12 14:42           ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 36+ messages in thread
From: David C. Hoos, Sr. @ 2001-09-12  9:10 UTC (permalink / raw)
  To: comp.lang.ada; +Cc: simon

As shown in an earlier posting, the disabling of style checks
can be very specific and localized, so turning off style checks
for the RCS/CVS strings does not compromise warnings in general.

I use $Source which is even longer, with no problem.

----- Original Message ----- 
From: "Simon Wright" <simon@pushface.org>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: September 11, 2001 12:53 AM
Subject: Re: avl tree - booch components


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Hmm. I agree it would be nice if you could have both CVS $Id$ and no
> warnings from the GNAT style check. However, given a choice between
> the two, I'll take the no warnings.

I will adopt a style like

--  $RCSfile: bc-containers-collections-ordered-bounded.ads,v $
--  $Revision: 1.5 $
--  $Date: 2001/09/11 05:29:27 $
--  $Author: simon $

(I don't _think_ the RCSfile is likely to break the limit)

> Do you ever actually read the output of CVS $Id$ ? What is it actually
> used for?

At a pinch I suppose RCSfile and Revision would be the minimum, but I
find the date very useful too especially when not connected to the
repository.

What file is this? what version? when did it last change? who changed
it? are all important. The last particularly so given multiple
users. I know it's all available from the repository (cvs status; cvs
log) but still ..

> Ignoring warnings in general is very bad practice, and it's too easy
> to go from "well, _this_ warning is ok" to "I checked all the warnings
> last week, I'll ignore them this time" to "just ignore the warnings".

How very true!
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada





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

* Re: avl tree - booch components
  2001-09-12  9:02           ` David C. Hoos, Sr.
@ 2001-09-12 10:37             ` Florian Weimer
  2001-09-13  5:51               ` Simon Wright
  0 siblings, 1 reply; 36+ messages in thread
From: Florian Weimer @ 2001-09-12 10:37 UTC (permalink / raw)


"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:

> Here is the relevant information:
>
> pragma Style_Checks
> Syntax:
> pragma Style_Checks (string_LITERAL | ALL_CHECKS | On | Off [, LOCAL_NAME]);

I've tried it, and with GNAT 3.13p, it doesn't work as expected:
'pragma Style_Checks (Off);' at the beginning of a compilation unit
has no effect (at least not on the context clause).



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

* Re: avl tree - booch components
  2001-09-12  9:10         ` David C. Hoos, Sr.
@ 2001-09-12 14:42           ` Warren W. Gay VE3WWG
  2001-09-13  5:57             ` Simon Wright
  2001-09-13 13:49             ` Georg Bauhaus
  0 siblings, 2 replies; 36+ messages in thread
From: Warren W. Gay VE3WWG @ 2001-09-12 14:42 UTC (permalink / raw)


David C. Hoos, Sr. wrote:

> As shown in an earlier posting, the disabling of style checks
> can be very specific and localized, so turning off style checks
> for the RCS/CVS strings does not compromise warnings in general.
> 
> I use $Source which is even longer, with no problem.


HP's ident command does not report the $Id: ...$ lines, so we've
adopted the habit of using $Header: ...$, but I suspect that
almost all other platforms work with $Id$ OK.

Having :

	CVSID: constant String := "$Header$";

embedded strings of course, lets you identify what your binaries
are built with -- an extremely useful tool for working with
production level binaries.

 From the HPUX-11 man page for ident(1) :

DESCRIPTION
       ident searches the named files for all occurrences of the pattern
       $keyword:...$, where keyword is one of the following:

            Author              Log
            Date                Revision
            Header              Source
            Locker              State

> ----- Original Message ----- 
> From: "Simon Wright" <simon@pushface.org>
> Newsgroups: comp.lang.ada
> To: <comp.lang.ada@ada.eu.org>
> Sent: September 11, 2001 12:53 AM
> Subject: Re: avl tree - booch components
> 
> 
> Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:
> 
> 
>>Hmm. I agree it would be nice if you could have both CVS $Id$ and no
>>warnings from the GNAT style check. However, given a choice between
>>the two, I'll take the no warnings.
>>
> 
> I will adopt a style like
> 
> --  $RCSfile: bc-containers-collections-ordered-bounded.ads,v $
> --  $Revision: 1.5 $
> --  $Date: 2001/09/11 05:29:27 $
> --  $Author: simon $
> 
> (I don't _think_ the RCSfile is likely to break the limit)


-- 
Warren W. Gay VE3WWG
http://members.home.net/ve3wwg




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

* Re: avl tree - booch components
  2001-09-12 10:37             ` Florian Weimer
@ 2001-09-13  5:51               ` Simon Wright
  0 siblings, 0 replies; 36+ messages in thread
From: Simon Wright @ 2001-09-13  5:51 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> writes:

> "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:
> 
> > Here is the relevant information:
> >
> > pragma Style_Checks
> > Syntax:
> > pragma Style_Checks (string_LITERAL | ALL_CHECKS | On | Off [, LOCAL_NAME]);
> 
> I've tried it, and with GNAT 3.13p, it doesn't work as expected:
> 'pragma Style_Checks (Off);' at the beginning of a compilation unit
> has no effect (at least not on the context clause).

Yes, now I remember! I think this is a 3.14 thing too, will check
whether I've reported it already ..



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

* Re: avl tree - booch components
  2001-09-12 14:42           ` Warren W. Gay VE3WWG
@ 2001-09-13  5:57             ` Simon Wright
  2001-09-13 13:49             ` Georg Bauhaus
  1 sibling, 0 replies; 36+ messages in thread
From: Simon Wright @ 2001-09-13  5:57 UTC (permalink / raw)


"Warren W. Gay VE3WWG" <ve3wwg@home.com> writes:

> Having :
> 
> 	CVSID: constant String := "$Header$";
> 
> embedded strings of course, lets you identify what your binaries
> are built with -- an extremely useful tool for working with
> production level binaries.

I have done this with GNU C, but was disappointed to find that GNU C++
suppressed unreferenced static strings.

Also, there is a potential problem with headers (well, I guess all you
have to do is put the $Id$ inside the
  #ifndef _this_file_has_been_read_already_
 thing).



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

* Re: avl tree - booch components
  2001-09-12 14:42           ` Warren W. Gay VE3WWG
  2001-09-13  5:57             ` Simon Wright
@ 2001-09-13 13:49             ` Georg Bauhaus
  2001-09-13 22:12               ` Jeffrey Carter
  1 sibling, 1 reply; 36+ messages in thread
From: Georg Bauhaus @ 2001-09-13 13:49 UTC (permalink / raw)


Warren W. Gay VE3WWG <ve3wwg@home.com> wrote:
 
: Having :
: 
:        CVSID: constant String := "$Header$";
: 
: embedded strings of course, lets you identify what your binaries
: are built with -- an extremely useful tool for working with
: production level binaries.

Yes, yes, and yes! (plugin: it is even more nice having the
PRCS $Format: ...$ facility available, which provides 
some control over what is inserted by the VCS.)



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

* Re: avl tree - booch components
  2001-09-13 13:49             ` Georg Bauhaus
@ 2001-09-13 22:12               ` Jeffrey Carter
  2001-09-14 13:38                 ` Warren W. Gay VE3WWG
  2001-09-14 13:59                 ` Marin David Condic
  0 siblings, 2 replies; 36+ messages in thread
From: Jeffrey Carter @ 2001-09-13 22:12 UTC (permalink / raw)


> Warren W. Gay VE3WWG <ve3wwg@home.com> wrote:
> 
> Having :
>
>        CVSID: constant String := "$Header$";
>
> embedded strings of course, lets you identify what your binaries
> are built with -- an extremely useful tool for working with
> production level binaries.

Unless the constant is never referenced, and your compiler optimizes it
away.

-- 
Jeffrey Carter



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

* Re: avl tree - booch components
  2001-09-13 22:12               ` Jeffrey Carter
@ 2001-09-14 13:38                 ` Warren W. Gay VE3WWG
  2001-09-14 14:54                   ` Simon Wright
  2001-09-14 13:59                 ` Marin David Condic
  1 sibling, 1 reply; 36+ messages in thread
From: Warren W. Gay VE3WWG @ 2001-09-14 13:38 UTC (permalink / raw)


Jeffrey Carter wrote:

>>Warren W. Gay VE3WWG <ve3wwg@home.com> wrote:
>>Having :
>>
>>       CVSID: constant String := "$Header$";
>>
>>embedded strings of course, lets you identify what your binaries
>>are built with -- an extremely useful tool for working with
>>production level binaries.
> 
> Unless the constant is never referenced, and your compiler optimizes it
> away.


That has never been my experience under GNAT, and never my

experience under C/C++.
-- 
Warren W. Gay VE3WWG
http://members.home.net/ve3wwg




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

* Re: avl tree - booch components
  2001-09-13 22:12               ` Jeffrey Carter
  2001-09-14 13:38                 ` Warren W. Gay VE3WWG
@ 2001-09-14 13:59                 ` Marin David Condic
  2001-09-14 14:08                   ` Marin David Condic
  1 sibling, 1 reply; 36+ messages in thread
From: Marin David Condic @ 2001-09-14 13:59 UTC (permalink / raw)


I thought there was a pragma - probably GNAT specific - that let you put
strings into a binary build for identification purposes. Can't recall at the
moment what it was, but I'm pretty sure it was there.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Jeffrey Carter" <jeffrey.carter@boeing.com> wrote in message
news:3BA12F31.D75C1280@boeing.com...
> > Warren W. Gay VE3WWG <ve3wwg@home.com> wrote:
> >
> > Having :
> >
> >        CVSID: constant String := "$Header$";
> >
> > embedded strings of course, lets you identify what your binaries
> > are built with -- an extremely useful tool for working with
> > production level binaries.
>
> Unless the constant is never referenced, and your compiler optimizes it
> away.
>
> --
> Jeffrey Carter





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

* Re: avl tree - booch components
  2001-09-14 13:59                 ` Marin David Condic
@ 2001-09-14 14:08                   ` Marin David Condic
  2001-09-14 16:50                     ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 36+ messages in thread
From: Marin David Condic @ 2001-09-14 14:08 UTC (permalink / raw)


Found something in the GNAT RM that looks like it does the job:

pragma Ident
Syntax:
pragma Ident (static_string_EXPRESSION);

This pragma provides a string identification in the generated object file,
if the system supports the concept of this kind of identification string.
The maximum permitted length of the string literal is 31 characters. This
pragma is allowed only in the outermost declarative part or declarative
items of a compilation unit. On OpenVMS systems, the effect of the pragma is
identical to the effect of the DEC Ada 83 pragma of the same name.



Obviously not a standard Ada pragma but if your project is strictly GNAT
specific, you'd be all right using it to get appropriate strings into a
binary. Perhaps there should be a mechanism in Ada0x for this purpose?

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> wrote in
message news:9nt2fq$d82$1@nh.pace.co.uk...
> I thought there was a pragma - probably GNAT specific - that let you put
> strings into a binary build for identification purposes. Can't recall at
the
> moment what it was, but I'm pretty sure it was there.
>






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

* Re: avl tree - booch components
  2001-09-14 13:38                 ` Warren W. Gay VE3WWG
@ 2001-09-14 14:54                   ` Simon Wright
  2001-09-14 16:47                     ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 36+ messages in thread
From: Simon Wright @ 2001-09-14 14:54 UTC (permalink / raw)


"Warren W. Gay VE3WWG" <ve3wwg@home.com> writes:

> Jeffrey Carter wrote:
> > Unless the constant is never referenced, and your compiler optimizes it
> > away.
> 
> That has never been my experience under GNAT, and never my
> experience under C/C++.

With foo.cc containing

  static const char rcsid[] = "hello world";
  int main()
  {
    return 0;
  }

I get

  orm[410]$ c++ -v
  Reading specs from /usr/lib/gcc-lib/i386-slackware-linux/egcs-2.91.66/specs
  gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
  orm[411]$ c++ -O2 foo.cc
  orm[412]$ strings a.out | grep hello
  orm[413]$ c++ foo.cc
  orm[414]$ strings a.out | grep hello
  hello world

(but gcc retains the string even with -O2)

-- 
Simon Wright                         Email: simon.j.wright@amsjv.com
Alenia Marconi Systems                     Voice: +44(0)23 9270 1778
Integrated Systems Division                  FAX: +44(0)23 9270 1800



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

* Re: avl tree - booch components
  2001-09-14 14:54                   ` Simon Wright
@ 2001-09-14 16:47                     ` Warren W. Gay VE3WWG
  0 siblings, 0 replies; 36+ messages in thread
From: Warren W. Gay VE3WWG @ 2001-09-14 16:47 UTC (permalink / raw)


Simon Wright wrote:

> "Warren W. Gay VE3WWG" <ve3wwg@home.com> writes:
>>Jeffrey Carter wrote:
>>
>>>Unless the constant is never referenced, and your compiler optimizes it
>>>away.
>>>
>>That has never been my experience under GNAT, and never my
>>experience under C/C++.
> 
> With foo.cc containing
> 
>   static const char rcsid[] = "hello world";
>   int main()
>   {
>     return 0;
>   }
> 
> I get
> 
>   orm[410]$ c++ -v
>   Reading specs from /usr/lib/gcc-lib/i386-slackware-linux/egcs-2.91.66/specs
>   gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
>   orm[411]$ c++ -O2 foo.cc
>   orm[412]$ strings a.out | grep hello
>   orm[413]$ c++ foo.cc
>   orm[414]$ strings a.out | grep hello
>   hello world
> 
> (but gcc retains the string even with -O2)


Ouch! You're right. This doesn't happen under HPUX with their C++

compiler, but obviously gcc is behaving differently.
-- 
Warren W. Gay VE3WWG
http://members.home.net/ve3wwg




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

* Re: avl tree - booch components
  2001-09-14 14:08                   ` Marin David Condic
@ 2001-09-14 16:50                     ` Warren W. Gay VE3WWG
  0 siblings, 0 replies; 36+ messages in thread
From: Warren W. Gay VE3WWG @ 2001-09-14 16:50 UTC (permalink / raw)


Marin David Condic wrote:

> Found something in the GNAT RM that looks like it does the job:
> 
> pragma Ident
> Syntax:
> pragma Ident (static_string_EXPRESSION);
> 
> This pragma provides a string identification in the generated object file,
> if the system supports the concept of this kind of identification string.
> The maximum permitted length of the string literal is 31 characters. This
> pragma is allowed only in the outermost declarative part or declarative
> items of a compilation unit. On OpenVMS systems, the effect of the pragma is
> identical to the effect of the DEC Ada 83 pragma of the same name.
> 
> Obviously not a standard Ada pragma but if your project is strictly GNAT
> specific, you'd be all right using it to get appropriate strings into a
> binary. Perhaps there should be a mechanism in Ada0x for this purpose?

I totally agree. This is a feature that is very important to any kind
of production support. For my purposes, the GNAT pragma will do, though
it irks me to use non-standard features. :-(
-- 
Warren W. Gay VE3WWG
http://members.home.net/ve3wwg




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

* Re: avl tree - booch components
  2001-09-10  6:59     ` Dave Parsons
@ 2001-09-26 14:00       ` Tony Gair
  0 siblings, 0 replies; 36+ messages in thread
From: Tony Gair @ 2001-09-26 14:00 UTC (permalink / raw)



Thanks for the help guys, 
 The usage of the package difficulty was in the end
more of a problem on the usage of ada 95 generics and my
own rather small brain.

I've managed to instatiate my own AVL Tree for chosen datatype
and am now trying to put this into a protected type, does anyone
know if I need a storage pragma ?

Regards
Tony Gair



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

* Re: avl tree - booch components
  2001-09-09 18:27   ` Simon Wright
                       ` (4 preceding siblings ...)
  2001-09-10 16:21     ` Stephen Leake
@ 2002-02-25 14:04     ` Dave Parsons
  2002-02-26  1:05       ` Matthew Heaney
  5 siblings, 1 reply; 36+ messages in thread
From: Dave Parsons @ 2002-02-25 14:04 UTC (permalink / raw)


On Sun, 9 Sep 2001 18:27:48, Simon Wright <simon@pushface.org> wrote:

> dwparsons@t-online.de (Dave Parsons) writes:
> 
> > Yes, I compiled all the tests and demos last weekend.  I had to turn
> > off the style checking though, too many lines too long.
> 
> -gnaty gives errors on 3.13p, I'm used to warnings with 3.14a1. Sorry.

Just built 3.14p under OS/2 and they do now all compile using -gnaty.

You do get a _lot_ of warnings ;-)

Dave




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

* Re: avl tree - booch components
  2002-02-25 14:04     ` Dave Parsons
@ 2002-02-26  1:05       ` Matthew Heaney
  0 siblings, 0 replies; 36+ messages in thread
From: Matthew Heaney @ 2002-02-26  1:05 UTC (permalink / raw)



"Dave Parsons" <DWParsons@T-Online.de> wrote in message
news:Ej0w7lFo08Zw-pn2-DEkmoMk2CdZJ@jupiter.dwparsons.dialin.t-online.de...
> Just built 3.14p under OS/2 and they do now all compile using -gnaty.
>
> You do get a _lot_ of warnings ;-)

If anyone is interested, the "charles" data structure library comes with a
red-black tree, which stays balanced during insertions and deletions.

http://home.earthlink.net/~matthewjheaney/charles/charles-red_black_trees__a
ds.htm
http://home.earthlink.net/~matthewjheaney/charles/index.htm
http://home.earthlink.net/~matthewjheaney/charles-20020213.zip

The tree type is really intended to implement some higher-level abstraction.
For example, it is used to implement all the map and set types in the
library.  It's probably easier to use those, instead of using the tree type
directly.










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

end of thread, other threads:[~2002-02-26  1:05 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-07  8:16 avl tree - booch components Tony Gair
2001-09-07 11:47 ` Des Walker
2001-09-07 14:51   ` Simon Wright
2001-09-07 22:04     ` Ehud Lamm
2001-09-07 23:59     ` Des Walker
2001-09-08 13:58       ` Tony Gair
2001-09-09  8:49 ` Dave Parsons
2001-09-09 18:27   ` Simon Wright
2001-09-09 19:22     ` Simon Wright
2001-09-12  7:48       ` Dave Parsons
2001-09-09 21:01     ` Dave Parsons
2001-09-10  6:59     ` Dave Parsons
2001-09-26 14:00       ` Tony Gair
2001-09-10  6:59     ` Dave Parsons
2001-09-10 16:21     ` Stephen Leake
2001-09-10 19:18       ` Pascal Obry
2001-09-11  5:45         ` Simon Wright
2001-09-12  9:02           ` David C. Hoos, Sr.
2001-09-12 10:37             ` Florian Weimer
2001-09-13  5:51               ` Simon Wright
2001-09-11  5:53       ` Simon Wright
2001-09-12  9:10         ` David C. Hoos, Sr.
2001-09-12 14:42           ` Warren W. Gay VE3WWG
2001-09-13  5:57             ` Simon Wright
2001-09-13 13:49             ` Georg Bauhaus
2001-09-13 22:12               ` Jeffrey Carter
2001-09-14 13:38                 ` Warren W. Gay VE3WWG
2001-09-14 14:54                   ` Simon Wright
2001-09-14 16:47                     ` Warren W. Gay VE3WWG
2001-09-14 13:59                 ` Marin David Condic
2001-09-14 14:08                   ` Marin David Condic
2001-09-14 16:50                     ` Warren W. Gay VE3WWG
2002-02-25 14:04     ` Dave Parsons
2002-02-26  1:05       ` Matthew Heaney
2001-09-10 21:52 ` Jeffrey D. Cherry
2001-09-10 21:53 ` Jeffrey D. Cherry

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