Posted by Thomas Mlynarczyk on 10/19/05 22:16
Also sprach Henk Verhoeven:
> Your problem: php has no Set. But you can use an associative array and
> add unique keys for each node, with some not-null value as value.
> Something like this:
> $visitedKeys[getUniqueKey($node)] = true;
> Now you can check wheather the node was already visited by:
> isSet($visitedKeys[getUniqueKey($node)])
Thank you for your suggestion. The only problem is the getUniqueKey()
function. The only way I can think of is adding another special index to
each (sub-)array, but then I would a) modify the array and b) still not know
how to find a suitable key name (must be the same for all and one that is
not used in the tree structure). It is not possible to directly access the
symbol table?
Greetings,
Thomas
[Back to original message]
|