Add to SortedSet and its complexity

后端 未结 1 1546
野性不改
野性不改 2021-02-03 23:10

MSDN states the following SortedSet(T).Add Method :

If Count is less than the capacity of the internal array, this method is an O(1) operation.

相关标签:
1条回答
  • 2021-02-03 23:44

    The comment is simply wrong. Yes, it is a red-black tree, O(log(n)) for inserts. Taking a look with Reflector bears this out, the private AddIfNotPresent() method contains a while() loop to find the insertion point, using normal red-black node traversal.

    This doc bug has already been submitted by you-know-who.

    0 讨论(0)
提交回复
热议问题