高效的 Int32/Uint32 排序映射/稀疏数组
我正在寻找一个专门的(且快速的)Int32/UInt32 排序映射(最好比 System.Collections.Generic.SortedDictionary 更快,其中 K 是 Int32 或 UInt32)。
它将用作稀疏数组,.NET 有任何实现吗?
I'm looking for a specialized (and fast) Int32/UInt32 sorted map (that preferably is faster then System.Collections.Generic.SortedDictionary where K is either Int32 or UInt32).
It's going to be used as a sparse array, are there any implementations for .NET?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如评论中提到的,我会编写一个自定义集合,它使用 SortedDictionary 和常规 Dictionary 作为其后备存储。它会使内存使用量增加一倍,但它是查找和迭代的最佳性能。修改会比较慢,但听起来您最感兴趣的是快速访问。
As was mentioned in the comments, I'd write a custom collection that uses both a SortedDictionary and a regular Dictionary as its backing store. It doubles your memory usage, but it's the best performance for lookups and iteration. Modifications will be slower, but it sounds like you're mostly interested in fast accesses.