c# - 这是对带有重复项的 SortedList 的合理使用吗
问题描述
我有以下代码来制作带有重复键的列表。列表最多为 150 项,键值为 0..100。
public SortedList<double, Sector> sectors;
// ...
double theKey = 100.0 - sortValue;
while (sectors.Keys.Contains(theKey)) theKey += 0.00001;
sectors.Add(theKey, newSector);
这是一个合理的技巧还是有更好的类可以使用?
解决方案
推荐阅读
- c++ - 使用 new 运算符保留动态内存
- sql - MapReduce 作业继续以 map = 0%、reduce = 0% 运行数小时
- asp.net - IEnumerable
不包含 FirstOrDefaultAsync() 的定义 - c# - 有没有办法使用桌面桥自动匹配旧版应用程序和 UWP 包之间的构建版本?
- reactjs - React Native / Expo - 将图像传递到预览屏幕
- error-handling - 什么是 Rust 等价于 try-catch 语句?
- java - 数据未保存在数据库中
- node.js - 如何将参数从 Watson Assistant 传递到部署在 IBM Cloud 上的云函数
- java - 如何在java中使用星号模式显示名称
- r - 我应该使用什么函数来返回字符向量?