I have a std::vector<std::string>
of all the files in a directory:
// fileList
folder/file1
folder/file2
file3
file4.ext
and a std::set<std::string>
of filenames and the same for all used folder prefixes:
// set1
file2
file4.ext
// set2
folder
I need to generate the full (relative) paths to the ALL files in set1, but see no way of doing that without iterating over set2 set1.size()
times, multiplied by fileList.size()
UPDATE: some clarification:
Expected output for above example:
folder/file2
file4.ext
Proposed (inefficient?) solution, maybe too verbose and with stupid implementation:
// pseudo-code!
vector<string> allpossibleFullPaths( set1.size()*set2.size() );
vector<string> output;
foreach( prefix_in_set2 )
foreach( filename_in_set1 )
allpossibleFullpaths.push_back( set2[i] + "/" set1[i] )
foreach( filename_in_fileList )
files.push_back( find( fileList[i] in allpossibleFullPaths ) );
(fast pseudocode-ish) This seems very innefficient, is there a better way to make these matches?
Thanks!
PS: better still would be a way to keep track of doubles, so that I can warn the user about that.