"Casper" <> wrote in message
news:9a_Sc.25209$.. .
>
> > Why not store the file size information in the tree as well, and sort by
> > that? The performance should be much better than either a linked list
or an
> > array (insertion sort); the tree should be reasonably well balanced.
> >
> Sounds very very interesting! I am not 100% sure I understand how a
> fixed/immutable nested tree structure can be sorted by a node data
> member?! Would it work as a secondard access path to the structure? I
> would love to see a prototype example of the struct you have in mind!
>
> Sincerely,
> Casper
>
My apologies for the poorly worded statement: when building the tree, use
the filesize as the sort field.
You can find C++ code for simple binary trees very easily on the internet.
Without looking too hard I found this link:
http://www.cs.bu.edu/teaching/cs112/...0/binary-tree/
The code would have to be modified to deal with duplicate file sizes.
It appears that you aren't particularly interested in sorting by the
filename. After building the tree, you can traverse it in order by file
size; as you traverse you can pull out sets of files with the same size and
deal with them as you see fit.
Another possibility is finding and using a database api. Or, easier still,
writing a program to translate the file system into a file that can be
imported into a database, processing the data, export a file back out, and
write another program to deal with the exported data.
As you've indicated, you could also build two trees, one sorted by name, the
other by size; all refering to the same bank of file data.