I have a case of use in C # where I have to store with int
s Mapping is
-
int
s is set in a dense (but not packaged) from 1 to n where n is not known. - Cells will be loaded
- The marginal cost of each cell is ideal (as
list>
ort []
- I want to fill on demanding cells
What is the best structure for this?
A
list & lt; T & gt;
will work well (better than in thespace
) and coming out of it can give me a lot, but is anything better? As you do not write the best code code. - I want to fill on demanding cells
A dictionary & lt; Int, cell & gt;
Looks like a good match for me or you can easily find a list & lt; Cell & gt;
, and just make sure that you expand it where necessary:
public static zero EnsureCount & lt; T & gt; (List & lt; T & gt; list, integer number) {if (list.Count & gt; count) {return; } If (list.Capacity & lt; count) {// always the least dual capacity, // the number of required list expansions. Capacity = Math.Max (list.Capacity * 2, count); } List.AddRange (Enumerable.Repeat (default (t), list.Capacity-list.Count)); }
Comments
Post a Comment