0
\$\begingroup\$

I'm currently building an RPG Game and as such I intend to have a lot of items. In my current system I have a database of items stored in a JSON file which I read and then store the items in a generic List<>. My question is as the numbers of items grow should I be looking into using a better data structure to store my database? As I wonder if i'll be able to search the list in an appropriate time when there's potentially thousands of items.

\$\endgroup\$
1
\$\begingroup\$

In terms of performance, it probably isn't a problem until you have a few thousand items (which you say you may have).

As per the data-structure to keep them in memory, you should consider how you use it. In particular: Do you iterate over it? Do you search by some criteria? Do you insert or remove often?

Since you mention searching, you may consider to use Dictionary<TKey, TValue> or even Dictionary<TKey, List<TValue>> to serve as indexes to access the items you need.

Going forward, there is nothing wrong with choosing a database engine for your game. I'd suggest to give a look to SQLite.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the quick answer! I'll have a look into both of these suggestions and see which is best for my problem. \$\endgroup\$ – Yatoniea Feb 5 '17 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.