I need to set the value of an element in my sortedDictionary, accessed by index.
I.e.
sortedDictionary.Values[index] = value; // compile error
Note that the following is incorrect because it's accessed by key, not index.
sortedDictionary[index] = value; // incorrect
I came up with the following solution, but intuition tells me it's slow. I'm assuming that accessing by key is O(log N), and accessing by index is O(1), but I'm not certain.
sortedDictionary[sortedDictionary.ElementAt(index).Key] = value;
Some background:
I'm using SortedDictionary because I need fast inserts, deletes, lookups, and to be able to access neighbor elements. (i.e. next highest or next lowest.) Efficiency is important.