gpt4 book ai didi

F# 相当于 C# 中的 SortedDictionary

转载 作者:行者123 更新时间:2023-12-01 06:50:34 25 4
gpt4 key购买 nike

F# 新手我需要根据 float 存储一堆对象列表,其中列表集合根据 float 排序。我知道在 C# 中我会使用

SortedDictionary<float, List<obj>>

因为实现是一棵红黑树,允许 log(n) 插入和搜索。但是在 F# 中解决这种情况的最佳方法是什么。我尝试使用 SortedDitionary,但我无法引用 SortedDictionary[int] 来查找值,因此它基本上使它变得无用(我可能做错了)。

感谢帮助

最佳答案

语法是

sorteddictionary.[int]

然后它就如你所料的那样工作了

关于F# 相当于 C# 中的 SortedDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9869897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com