HP3000-L Archives

December 2001, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Roy Brown <[log in to unmask]>
Reply To:
Roy Brown <[log in to unmask]>
Date:
Thu, 27 Dec 2001 16:16:49 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (64 lines)
In message <[log in to unmask]>, Stan Sieler
<[log in to unmask]> writes
>Re:
>> tree.  Until now I've quite simply disallowed 'multiple parents', but
>> largely because my brain's too feeble to see a cleaner loop-avoidance
>> mechanism.
>...
>> ActA
>>  |-ActB
>
>As you "enter" an activity (ActA above would be the first), check in
>an (initially empty) "Activity Seen" table.  If it's there, you've got a loop,
>so don't recursively visit it (and take whatever action is appropriate).
>If it isn't there, add it to the table and recursively visit it.
>
>If your activities are small numbers,
>small letters, or something similar
>that can be used as an index into a small array, simply use the activity name
>as a index into a "seen_this_activity" bitmap.  Otherwise, use some other
>mechanism (chosen based on your expectation of average and worst-case number of
>activities).

But (IIUC) you don't need a table, with its N^2 comparison implications;
the only entry this table would need is ActC, the leaf being linked to.
And you can then look through the structure of ActA (the item being
linked) for ActC, without having to link ActC to ActA first, and then
possibly undo it later.



Re the recursive procedure required for tree-walking: some details.
Let's use an Image example. We put the Activities, ActA, ActB, ActC,
etc. in a Master set. (Well, actually, I'd use a Detail with an Auto
Master, but it's a 'logical' Master).

Then we put the parent-component links (ActA-ActB, ActC-ActD, etc) in a
Detail set, Structure, keyed off parent (the first, higher, item in each
link).

The recursive procedure then walks along the detail chain for a parent,
with a Perform Until End-Of-Chain or Loop-Found.

In the Perform, for each structure record found it checks if the
component is the 'ActC'; if so, we exit with 'Loop Found'. If not, it
calls itself for the component.

On return, if 'Loop Found', it exits. Otherwise it reads the next
structure record, and processes it as above.

At the end of the structure chain, it exits.

At final exit, it either reports Loop Found, or not; if not, the link
can be made.

There are implementation niceties of course, notably preserving Image
pointers at each level (Directed Reads are a better bet here than
multiple DBOpens!) , but the principle should be clear enough....
--
Roy Brown        'Have nothing in your houses that you do not know to be
Kelmscott Ltd     useful, or believe to be beautiful'  William Morris

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2