http://d.puremagic.com/issues/show_bug.cgi?id=8680



--- Comment #5 from Jesse Phillips <jesse.k.phillip...@gmail.com> 2012-09-18 
20:59:48 PDT ---
(In reply to comment #4)
> Are you saying you want a real breadth-first search to be implemented? Fine, 
> we
> can do that, if it's useful. Note though that it'll intersperse children, e.g.

No, but someone else did, which is fine. Probably not really needed as a
standard traversal type though.

> I intended those as alternative names instead of 'postorder' and 'preorder'
> (respectively) - I didn't intend to suggest any other behaviour.

I know, but they are descriptive of the two most useful traversal types I can
think of.

> What behaviour do you want?

I have only had two types of traversals.

I don't care: In this type of traversal I just need all the files and couldn't
care less when they come to me. In all cases I've never wished to have the
directory name (but don't wish for a traversal that leaves it out).

Parent First: Give me everything in the Parent First, then you can traverse the
children. Almost as you described, except it would be starting a breadth first
from each child.

The other traversal types are likely useful in other situations. I was close to
instead of using Parent First choosing

Child First: Give me what is in the Child First before that in the parent. This
turns the Parent First on its head.

> I would argue that that's very specific, not
> intuitive in the general case, and best implemented using two separate calls 
> to
> the function with different arguments:
> 
> auto firstLevel = dirEntries("a", SpanMode.shallow);
> foreach (file; firstLevel) {
>   if (file.isDir()) {
>     ... = dirEntries(file, SpanMode.preorder);
>   }
> }

This isn't as you described nor what I want. You'll notice all you did was
create a preorder search where you'll never see the top level directories. I'm
looking more at:

auto firstLevel = dirEntries("a", SpanMode.shallow);
foreach (file; firstLevel) {
   if (file.isDir()) {
     secondLevel ~= dirEntries(file, SpanMode.shallow);
   }
}

foreach(sl; secondLevel)
foreach (file; sl) {
   if (file.isDir()) {
     thirdLevel ~= dirEntries(file, SpanMode.shallow);
   }
}

foreach(tl; thirdLevel)
foreach (file; tl) {
   if (file.isDir()) {
     thirdLevel ~= dirEntries(file, SpanMode.shallow);
   }
}
....

On until you get tired of trying to predict how many levels this directory
actually has.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to