title: The right data structure to use for an Excel clone
body: <p>Let say I'm working on an Excel clone in C#.
  My grid is represented as follows:</p>
  
  <pre><code>private struct CellValue
  {
      private int column;
      private int row;
      private string text;
  }
  private List&lt;CellValue&gt; cellValues = new List&lt;CellValue&gt;();
  </code></pre>
  
  <p>Each time user add a text, I just package it as CellValue and add it into cellValues. Given a CellValue type, I can determine its row and column in O(1) time, which is great. However, given a column and a row, I need to loop through the entire cellValues to find which text is in that column and row, which is terribly slow. Also, given a text, I too need to loop through the entire thing. Is there any data structure where I can achive all 3 task in O(1) time?</p>
  
  <p>Updated:
  Looking through some of the answers, I don't think I had found one that I like. Can I:</p>
  
  <ol>
  <li>Not keeping more than 2 copies of CellValue, in order to avoid sync-ing them. In C world I would have made nice use of pointers.</li>
  <li>Rows and Columns can be dynamically added (Unlike Excel).</li>
  </ol>