C#: how best to implement a 2D sparse array of data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolsti
    Contributor
    • Mar 2008
    • 310

    C#: how best to implement a 2D sparse array of data?

    To the more experienced C# programmers, how do I do this best?

    I have a 2 dimensional mapping of values in a database, which represent a somewhat round (but not exactly round) shape when drawn out on paper. That is, the "row" coordinate values run from 1 to the maximum number of rows in the mapping, and the "column" coordinates run consecutively from a starting value to an ending value. In somewhat the middle of the mapping, the column coordinates will go from 1 to the maximum column count, but above and below this row, the column coordinates will start at values greater than 1 and end at values less than the maximum column count.

    In another database table, I will have the same 2 dimensional mapping but these will be a randomly sampled set of the round mapping, meaning that not all of the row and column coordinates will be present in this table.

    So now I want to pull out the data from these two tables, the complete round mapping of "row coordinate", "column coordinate" and "value" and store it in some sort of C# collection element, like a 2D array or array list or whatever is best. And I want to also extract the sampled mapping of "row coordinate", "column coordinate" and "sampled value" and store it in another collection in C#.

    What is best? An array list of hashes? An array of hashes? An array list of sorted lists? A sorted list of sorted lists?

    Important is the efficiency of locating the values of these collections when the user supplies a pair of values for the row and column coordinates.

    Thanks for any tips!
Working...