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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!ELCGL.EPFL.CH!MADMATS From: MADMATS@ELCGL.EPFL.CH ("", Mats Weber) Newsgroups: comp.lang.ada Subject: RE: Booch Graph Component Interator Question Message-ID: <901112220011.1ch@sic.epfl.ch> Date: 12 Nov 90 21:00:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: >I want to iterate over all the current vertices of the graph, >to see of one of them has a particular value of a charateristic >(for purposes of discussion, having a particular "name"). > >I instantiate the graph-package with a STRING to contain the name >as the vertex item, and a NATURAL to be a count as the arc attribute.>> > >[...] First, you should not ITERATE if what you want is FIND Second, for good reasons, few components will allow you to modify their structure while you are iterating on them. The graph component already gives you the mapping Vertex -> String What you seem to need is a mapping String -> Vertex, which you may obtain by instantiating a Map component. Then, once you have the name of the vertex you want to modify, search for the corresponding Vertex in your String -> Vertex map, and then modify that vertex accordingly. If you want to do some operation on all vertices, then iterate on the String -> Vertex map and modify the vertices within the graph from within that iterator. (You might have to use a String -> access Vertex mapping if the Map component does not provide a constructive iterator (on that allows you to modify subcomponents of the structure you are manipulating)). Answer to #4: Do not use a global variable, but instantiate the iterator within a procedure: function Number_Of_Vertices (G : in Graph) return Natural is Count : Natural := 0; procedure Count_Vertex (V : in Vertex) is begin Count := Count + 1; end; procedure Count_Vertices is new Iterate_Vertices(Count_Vertex); begin Count_Vertices(G); return Count; end; -- I'm not shure of the names, but you get the idea. Mats Weber Swiss Federal Institute of Technology EPFL DI LGL 1015 Lausanne Switzerland E-mail : madmats@elcgl.epfl.ch phone : +41 21 693 52 92 fax : +41 21 693 39 09