let's say I have the following data structure:
var someList= new List<int>[]{
new List<int>() {-1,-1,2},
new List<int>() {-1,0,1}
});
I need to able to avoid:
someList.Add(new int[] {-1,1,0});
since [-1,0,1] are in the set already and I cannot allow duplicate sets.
Values can come in any other and still I need to ensure that there are no duplicates. So [0,-1,1] or [1,-1,0] are basically the same set.
This data structure will receive thousands of entries.
What do you think is the best way to ensure uniqueness?
I thought about using a dictionary, however, I am not quite sure since I will be increasing the memory and probably processing and I wonder if it is avoidable.
HashSeteliminates duplicates. As for not being quite sure about memory and processing time: benchmark and profile. If your sets and/or your elements are always small there are many ways to optimize this in terms of storage and/or processing time, but premature optimization is the root of all evil.someArrayis an array of Lists, so it has noAddmethod.Addmethod. You can replace things at an index, but an array of length 2 will always have items in the array.