title: What data structures can efficiently store 2-d "grid" data?
body: <p>I am trying to write an application that performs operations on a grid of numbers, where each time a function runs the value of each cell is changed, and the value of each cell is dependent on its neighbours. The value of each cell would be a simple integer.</p>
  
  <p>What would be the best way of storing my data here? I've considered both a flat list/array structure, but that seems ineffective as I have to repeatedly do calculations to work out which cell is 'above' the current cell (when there is an arbitrary grid size) and nested lists, which doesn't seem to be a very good way of representing the data.</p>
  
  <p>I can't help but feel there must be a better way of representing this data in memory for this sort of purpose. Any ideas?</p>
  
  <p>(note, I don't think this is really a subjective question - but stack overflow seems to think it is.. I'm kinda hoping there's an accepted way this sort of data is stored)</p>