Impressed

Stuart stugol at gmx.com
Fri Jul 27 11:58:37 PDT 2012


On Friday, 27 July 2012 at 16:15:46 UTC, Jesse Phillips wrote:
>
> Taking a look at DirIteratorImpl[1] in std.file suggest there 
> is a lot of setup to navigate the filesystem on Windows. How 
> does Yield help with that logic?

Well, off the top of my head, you could use something like:

    Public Iterator Function AllFiles(RootDirectory As String) As 
IEnumerable(Of String)
       Dim Roots As New Queue(Of String) From {RootDirectory}
       While Roots.Any
          Dim Root = Roots.Pop
          Roots.AddRange(IO.Directory.GetDirectories(Root))
          For Each Filename in IO.Directory.GetFiles(Root)
             Yield Filename
          Next
       End While
    End Function



More information about the Digitalmars-d mailing list