[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    (followup) Re: [despammed] Best way to recursive folders?
From:       Mosfet <dan.duley () verizon ! net>
Date:       2003-05-04 15:31:07
[Download RAW message or body]

BTW, I implemented it this way and it's all good :) I didn't use a stack, I 
used a linked list because I already had one I coded for C, but it's the same 
concept. This is far faster than scanning for subdirectories first then 
processing them iteratively.

BTW II, after using C++ for so long I loathe C programming ;-)

On Saturday 03 May 2003 09:18 am, Mosfet wrote:
> Hey, that's a good approach - I'll use it! Thank you :)
>
> On Saturday 03 May 2003 02:38 am, Esben Mose Hansen wrote:
> > On Saturday 03 May 2003 02:41, Mosfet wrote:
>
> ...snip...
>
> > You can combine the above approaches: When scanning the first directory,
> > push any directories to a stack. When done with this directory, take the
> > top directory and process that in the same way. As this is tail
> > recursion, it can be replaced with a simple look. In psedo code, in
> > pseodu C++:
> >
> > stack<Directories> dirs_to_be_processed;
> > do {
> > 	for each file in diretory{
> > 		if (file is a directory)
> > 			dirs_to_be_processed.push(file);
> > 		processFile(file);
> > 	}
> > } while (!.stack.empty())
> >
> > This kind of approach often works like a charm when you want to rid
> > yourself of those nasty recursions :-)
> >
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic