I’m looking for a collection.
I need to be able to add elements as if using a 2D integer key, for example .Add(3, 4, element). If I add outside the range of the collection I need the collection to expand, this include negatively, although it can have a limit, for example the range of an Int16 would be good. Every element in the collection can have the same type as each other but I need to specify what that is, for example Set<type> s;
I also need to avoid slow operations such as searching when looking up an element, performance is less important when adding to the collection.
Does anyone have any ideas about what approach to use or best could provide the class in there answer.
If you want a compound key, you can use the
Tuple<T1,T2>class in a :Dictionary<Tuple<T1,T2>, TItem>.If the syntax is too weird, you may wrap the class like this :
The benefits of using Tuple class, is that the equality and hashcode comparison is natively handled, so even if it’s a class, two differents instances of tuple with same values will be considered equals.