We have map of string pairs like name:location (unix like absolute location a la myfolder/
). We are given with some location a la myfolder/mysubfolder/myfile
. How to find which of maps location fit to given url most?
Example we have a map like:
service1:myfolder/
service2:myfolder/mysubfolder/
service3:myfolder/myothersubfolder/
service4:myfolder/mysubfolder/myfile
We are given value myfolder/mysubfolder/myfile/blablabla/
(string).
We want to find out to which item in our map it relates the most.
Search result shall be service4
as map item with most related content.
So how to find by given string value to which map element it relates the most?
Please provide some code because I am C++ nube and do not get how to inplement such thing?
So I simplified a problem a bit - now all relation I need is in how deep given path is which in string case can be aceived by just iteratin over all maps paths looking at thare langth , searching for appearence in given path and remembering most long map item path found in given path.