SortedDictionary.Count cost

What is the cost SortedDictionary.Count

in C #? Is it getting some kind of integer or is it doing it through the tree?

+2


a source to share


3 answers


It just returns the value from the field, so the cost should be negligible.



+5


a source


Per documentation



Retrieving the value of this property is an O (1) operation.

+3


a source


O (1) because it's just accessing the field.

+2


a source







All Articles