Datastructure for a lot of "People"

Hi,
At the moment I am developing a simulation game.
As there will be many people(prob around 10000) in the game I want to sort the people to have only some 50 or 100 “active” and whe rest stored in a SQL database.
Has anybody an idea how to realize this? I don’t want to lose any people during the process if switching between active and passive.

Thanks in advance

Hello,
I think you should use ArrayList or HashMap those structures are mostly used, depending on what you need. And if you don’t want to lose any people during performance I suggest to implement checking then you switch between active, passive.
You also can have all those people in memory but don’t render passives that way you don’t lose any and you don’t need to ask SQL each time people state change.

This seems like a common “data persistance” problem, what about this:

  • You store everything on your DataBase
  • When you launch the server, at first its “active player list” is empty
  • When someone “becomes active”, you fetch information about him from the DB and store him in your player list
  • When someone “becomes passive”, you save the updated information to the DB and remove him from the player list
  • From times to times, you save everything to the DB, just in case