title: Need a cache friendly data structure to store the neighbors of a letter in a 2d-array
body: <p>Assume the following is a 2d array that we are operating on</p>
  
  <pre><code>a b c d
  e f g h
  i j k l
  m n o p
  </code></pre>
  
  <p>The surrounding neighbor of 'f' are [a b c e g i j k]. I'm trying to create a cache friendly data structure to store the neighbor of a node. Right now I have something like so</p>
  
  <pre><code>struct Neighbor{
     size_t neighborPosition[8][2];
     size_t size;
  };
  
  typedef size_t Position[2];
  typedef Neighbor** NeighborTable;
  </code></pre>
  
  <p>Note that the max neighbor a node could have is 8.  Anyone have any advice? I need the structure to be a constant time neighbor lookup so I will be pre-calculating the neighbor of  each node. </p>