开发者

Looking for efficient way to index files

I started working on a new home project, I need to index specific files names with there paths. The program will index files on my local hard-disk with no need to deal with the contents of the files (so I assuming/hoping it would be simple implementation). At first the user will insert a list of file extensions to get indexed (During setup time). Then the program will run and create the data structure holding the path for the specific file entered by the user.

Retrieving data from by data structure would look like this:

path of the file on my HDD=function(filename entered by user)

I thought about it for quite a while and wrote a design for the data structure here is my suggestio开发者_开发问答n (Design Illustration):

  1. I'll use an array with a hash function for mapping extension to a cell (Each cell presents the

    first letter of the extension file).

  2. inside each cell there would be a list of extensions starting with the same letter.

  3. for each node in the list there would be a red black tree for searching the filename and then after we found the filename the program will retrieve the path of the file stored in the tree

    node.

Oh by the way usually I program in c (low level) or in c++.


I think you are making a way too elaborate and complicated scheme. If locating a MyFileTree based on extension is what you want then just use SortedDictionary<string, MyFileTree> where string is your extension and you'll get a O(log n) retrieval mechanism out of the box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜