I am having trouble implementing the following in a performance efficient way....


I have a number of particles which are randomly moving through a 'grid', every time a particle moves, its coordinates are checked to make sure they are valid.

I.E. there is a class called particle which contains the boolean function valid... every time a particle is moved, its x coord and y coord are updated (using a random number) and the valid function is called to see if the location the particle has moved to is valid.

I have a list of specific coordinates which are 'invalid'

What is the most efficient way of checking if e.g. coordinate x=57, y=88 is valid?

The problem is that the grid is approx 10,000 by 10,000 and there are around 100,000 'invalid' coordinates so I don't really want to have to loop through every coordinate every time as it takes ages...


I have thought of using 2-d arrays where I declare bool valids[10000][10000] and then use the array locations as coordinates, i.e. check to see if valids[57][88] is true.... but my program keeps on crashing...

is there a more efficient way, maybe using vectors or maps....

Thanks