问题标签 [sorteddictionary]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
6091 浏览

c# - SortedDictionary (C#) - 改变值

在 SortedDictionary 中是否可以更改项目的值?

0 投票
7 回答
107949 浏览

c# - SortedList 和 SortedDictionary 有什么区别?

SortedList<TKey,TValue>a和 a之间有什么真正的实际区别SortedDictionary<TKey,TValue>吗?在任何情况下您会专门使用一种而不是另一种吗?

0 投票
1 回答
2186 浏览

c# - 如何使用 Eval() 在 asp 中继器中引用 SortedDictionary 中的值?

我认为我很聪明地从内存密集型 DataView 切换到 SortedDictionary 作为内存高效的可排序数据结构。现在我不知道如何在 <%# 或 Eval() 表达式中从数据源中获取键和值。

有什么建议么?

0 投票
2 回答
290 浏览

f# - 使用 readlock 和 writelock 同步 SortedDictionary.iteri

当我使用 iteri 函数时,我应该把 readLock 放在哪里?

0 投票
6 回答
46671 浏览

c# - 何时使用 SortedList在 SortedDictionary 上?

这似乎是这个问题的重复,它询问“ SortedListSortedDictionary之间有什么区别?” 不幸的是,答案只不过是引用了 MSDN 文档(其中明确指出两者之间存在性能和内存使用差异),但实际上并没有回答这个问题。

事实上(所以这个问题没有得到相同的答案),根据 MSDN:

SortedList<TKey, TValue>泛型类是具有 O(log n) 检索的二叉搜索树,其中 n 是字典中元素的数量。在这方面,它类似于 SortedDictionary<TKey, TValue>泛型类。这两个类具有相似的对象模型,并且都具有 O(log n) 检索。这两个类的不同之处在于内存使用和插入和删除速度:

  • SortedList<TKey, TValue>使用的内存少于SortedDictionary<TKey, TValue>.

  • SortedDictionary<TKey, TValue>对未排序的数据具有更快的插入和删除操作,O(log n) 而不是 O(n) for SortedList<TKey, TValue>.

  • 如果列表是从排序的数据中一次性填充的,SortedList<TKey, TValue>则比 SortedDictionary<TKey, TValue>.

因此,显然这表明这SortedList<TKey, TValue>是更好的选择,除非您需要对未排序的数据进行更快的插入和删除操作。

鉴于上述信息,问题仍然存在,使用SortedDictionary<TKey, TValue>? 根据性能信息,这意味着根本没有必要拥有SortedDictionary<TKey, TValue>

0 投票
1 回答
2802 浏览

c# - 设置 SortedDictionary 的第 i 个值

我需要在我的 sortedDictionary 中设置一个元素的值,通过索引访问。

IE

请注意,以下内容不正确,因为它是通过键而不是索引访问的。

我想出了以下解决方案,但直觉告诉我它很慢。我假设按键访问是O(log N),索引访问是O(1),但我不确定。

一些背景:

我使用 SortedDictionary 是因为我需要快速插入、删除、查找以及能够访问相邻元素。(即次高或次低。)效率很重要。

0 投票
6 回答
53247 浏览

c# - SortedList<>、SortedDictionary<> 和 Dictionary<>

我发现SortedList<TKey, TValue> SortedDictionary<TKey, TValue>Dictionary<TKey, TValue>实现了相同的接口。

  1. 我们什么时候应该选择SortedListSortedDictionary结束Dictionary
  2. SortedList在应用方面和SortedDictionary方面有什么区别?
0 投票
5 回答
18550 浏览

c# - 获取 SortedDictionary 中的最后一个元素

我看到了这个问题

如何在 .Net 3.5 中获取 SortedDictionary 中的最后一个元素。

0 投票
3 回答
4276 浏览

vb.net - SortedDictionary 行为

我在我的应用程序中使用了 SortedDictonary(Of String, String),我遇到了一种奇怪的排序行为。考虑以下代码示例:

我希望键被排序为“'A”,“'B”,“'C”,“A”,“B”,“C”,这是你在“手动”比较键时得到的,通过 < 运算符。然而,遍历键返回“A”、“'A”、“B”、“'B”、“C”、“'C”。

如何更改 SortedDictionary 行为以对以'first 开头的单词进行排序?

谢谢你,CFP

0 投票
1 回答
16612 浏览

.net - SortedList vs. SortedDictionary vs. Sort()

是类似问题的延续。

是否有任何调整性能的指导方针?我不是说大 O 的收益,只是节省一些线性时间。

例如,预分类在SortedList或上节省了多少SortedDictionary

假设我有一个人类,有 3 个属性要排序,其中一个是年龄。我应该先按年龄存储对象吗?

我是否应该首先对一个属性进行排序,然后使用生成的列表/字典对两个属性进行排序等等?

想到其他优化吗?