Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which data structure should be best used to store a pile of tiles from which a player can pick a random tile?

share|improve this question
We need more information to give a good answer (more...) – CiscoIPPhone Apr 26 '11 at 11:48
For example, will you be adding tiles to the structure? Will you be removing tiles from the structure? – CiscoIPPhone Apr 26 '11 at 11:48
up vote 2 down vote accepted

I'd suggest any container that has random access (wikipedia), for example a plain array, vector, or deque.

int tiles[100];


std::vector<int> tiles;

This will allow you to select a random element without having to step through the container.

I have left a comment asking for more information, if more information is added I'll update this answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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