因此,我們有一組文件名\ url,如file, folder/file, folder/file2, folder/file3, folder/folder2/fileN
等。我們給出了一個字符串,如folder/
。我們想要找到folder/file
,folder/file2
,folder/file3
,並且最有趣的是folder/folder2/
(我們不想列出forlder2的內容,只是表明它存在並且可以被搜索到)。通過STL和Boost可以實現這種功能嗎?以及如何做到這一點?有一個只有文件名(a,f/a,f/b,f/f/c等)的std :: set如何通過給定的f /來列出目錄?
UPS - 剛剛發現我已經loocked對於這個曾經在不久前here ......但還沒有找到正確的答案了......
嘗試'substr()'。一個合適的數據結構可能是一個*前綴樹*(或「trie」),但是對於少數不應該是必需的元素。 –
爲什麼你在std :: set中使用它?根據您的要求定製自定義類。 – balki
[set可能重複:如何列出不以給定字符串開頭並以'/'?]結尾的字符串(http://stackoverflow.com/questions/7169320/setstring-how-to-list-not-strings-開始與 - 給串和結束的,有) –
Rella