带有比较器的 TreeSet 的 Big-O 是什么?

What is the Big-O of a TreeSet with a comparator?

我正在使用它根据每个对象的特定属性(例如:日期和数量)对对象进行排序。当我将比较器附加到 TreeSet 时,当我向其中添加 N 个值并让它自行排序时,我将获得什么类型的性能?

来自 the documentation for TreeSet,强调我的:

This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).

假设您的比较器相对于集合的大小(通常是)为 O(1),那么您选择的比较器并不重要。

您插入的值的数量与插入操作本身的复杂性分析无关。