c#结构,如std::set,支持lower_bound

C# structure like std::set that supports lower_bound

本文关键字:lower bound 支持 set std 结构      更新时间:2023-10-16

我需要一个内置的数据结构在C#具有类似于std::set(或std::map)在c++中的功能。对我来说重要的是,结构应该排序(因此Dictionary不会在这里做),并有一个类似于lower_bound的方法(即返回值至少为v的第一个元素)。我还需要从结构中插入和删除元素。如果可能的话,我需要这些操作的复杂度为O(log(n))。您能告诉我C#中合适的数据结构吗?

我怀疑您正在寻找与std::set类似的数据结构的SortedSet。

本文探讨其性能特点。

lower_bound功能似乎可以使用SortedSet。GetViewBetween的复杂度比期望的O(log(n))要低