c# - Store and search directory tree in memory efficiently -


i want store directories on huge drive efficiently in memory possible , able retrieve directory given it's full path. each directory has fields it's name (not it's full path) , pointer it's parent , list of subdirectories. way think way go is?

as see there's couple of ways:

a) store full paths each directory in dictionary , simple lookup. pros: fast, cons: each full path string takes uneccessary , redundant amount of memory

b) store actual directory name in dictionary list of directories name, check matches if it's correct: pros: pretty fast, cons: has either store list each directory or use boxing store either list or directory in dictionary.

c) skip dictionary, traverse tree root , find match splitting path. perhaps use plinq speed things up. pros: no memory overhead dictionary, cons: potentially slower lookup.

d) other way haven't thought of...

if store subdirectories dictionary rather list (and cases want subdirectories, that's done using values property) can step through path each step being o(1) , hence complexity of finding directory full path being o(n) n number of steps in path, not related number of directories in system.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -