My requirement is that I am making an application for WP7 so I have to take care of memory consumption by objects. I m having data of about 1000 records that to hard coded data. So dictionary will be easily accessible than 2D array but is it consume more memory than 2D array. Also which will be fast in doing search. Ya I know search will be fast in dictionary where we can easily get the value for corresponding key by giving key, but is it internally do the linear search.
Share
Go with dictionaries. 1000 records isn’t a lot. And the code for searches in dictionaries is really simple:
whereas the code for searches in 2D arrays, well. Are you sorting your arrays? That could make finding stuff faster. But also more complicated than doing a linear search. You’d then need to make sure the sorted property stays invariant.
Oh, and then you’ll have to maintain yet another lookup implementation.
Don’t go there!
When you run out of memory, then maybe you can start thinking about optimizing the dictionary to some other structure. But you won’t run out of memory. YAGNI.