ID:               32439
 User updated by:  Peter dot Albertsson at naturesown dot se
 Reported By:      Peter dot Albertsson at naturesown dot se
 Status:           Wont fix
 Bug Type:         Feature/Change Request
 Operating System: *
 PHP Version:      5.*
 Assigned To:      helly
 New Comment:

I don't see how breadth first would break something that depth first
doesnt't. The algorithm for breadth first is of  no higher complexity
in time or memory requirements, and it certainly doesn't contradicts
the idea of iterators. You say breadth first insults full caching of
the results, I'm not sure what you mean and why would it do so? 

I didn't mean that PHP have a tree structure (or need one), but one
wouldn't use a RecursiveIteratorIterator on something that doesn't look
like a tree, let it be a directory tree or whatever tree structured data
that one have.

Well, I already have these things implemented in PHP (if there is an
interest, I can publish it somewhere).

The left to right or right to left functionality is best implemented at
the RecursiveIterator level so that is what I have done, while depth
first or breadth first is implemented at the RecursiveIteratorIterator
level.

As a bonus, a depth limit option is available too, that simply prevents
the iterator to go deeper than a chosen level.

My skill level in C will not allow me to do any fixes, but I'm working
on that part. ;)

So, if anyone is interested in the PHP classes I wrote for iterating
tree like structures in any direction, let me know.

Best Regards,

   Peter Albertsson


Previous Comments:
------------------------------------------------------------------------

[2005-03-24 11:04:30] [EMAIL PROTECTED]

Directions:
1. Depth first or - we have that
2. Breadth first - that would insult full caching o fthe results which
contradicts the ide of Iterators. If you want this do it in userland.
For example you can use the function iterator_to_array() that is
available in 5.1.

combined with one of:
1. Left to right
2. Right to left

Both require that the thing works on a tree structure - well we don't
have a tree structure or object. And even if we had we would provide
some tree walker methods and of course won't use the iterator stuff.

If you now you think you need tree's and everythink feel free to check
out extension adt and get it fixed.

sorry nothing we can do atm.



------------------------------------------------------------------------

[2005-03-24 02:09:13] Peter dot Albertsson at naturesown dot se

Description:
------------
The RecursiveIteratorIterator is not flexible enough when it comes to
iterating trees. I also find some modes it operates in unneccasary.

I would like to choose in which directions the iterator iterates
through trees:

1. Depth first or
2. Breadth first

combined with one of:

1. Left to right
2. Right to left

As the iterator is implemented today, it lacks the method of iterating
breadth first. Instead I'm giving these options:

 - RIT_LEAVES_ONLY: very easy to implement by oneself, by checking if
the node is a leaf node.
 - RIT_SELF_FIRST: This one I would consider the default option. but it
is not.
 - RIT_CHILD_FIRST: OK.. got to admit that I don't even understand this
one...

Most importantly, and I repeat, it lacks the option to iterate breadth
first, which is required by many standard algorithms.

Best Regards,

  Peter Albertsson



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32439&edit=1

Reply via email to