OneToManySortedDictionary<TKey, TSortedKey, TValue> 类
一对多映射关系的排序字典。每个外部键映射到一个内部排序字典,该内部排序字典将排序键映射到相应的值。
继承
Dictionary<TKey, SortedDictionary<TSortedKey, TValue>>
OneToManySortedDictionary<TKey, TSortedKey, TValue>
实现
IDictionary<TKey, SortedDictionary<TSortedKey, TValue>>
IReadOnlyDictionary<TKey, SortedDictionary<TSortedKey, TValue>>
继承成员
命名空间: Fantasy.DataStructure.Dictionary
程序集: Fantasy.Net.dll
语法
public class OneToManySortedDictionary<TKey, TSortedKey, TValue> : Dictionary<TKey, SortedDictionary<TSortedKey, TValue>>, IDictionary<TKey, SortedDictionary<TSortedKey, TValue>>, ICollection<KeyValuePair<TKey, SortedDictionary<TSortedKey, TValue>>>, IReadOnlyDictionary<TKey, SortedDictionary<TSortedKey, TValue>>, IReadOnlyCollection<KeyValuePair<TKey, SortedDictionary<TSortedKey, TValue>>>, IEnumerable<KeyValuePair<TKey, SortedDictionary<TSortedKey, TValue>>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable where TKey : notnull where TSortedKey : notnull
类型参数
名称 | 描述 |
---|---|
TKey | 外部字典中的键类型。 |
TSortedKey | 内部字典中的排序键类型。 |
TValue | 内部字典中的值类型。 |
构造函数
| 编辑本文 查看源代码OneToManySortedDictionary()
声明
protected OneToManySortedDictionary()
OneToManySortedDictionary(int)
创建一个新的 OneToManySortedDictionary<TKey, TSortedKey, TValue> 实例。设置最大缓存数量
声明
public OneToManySortedDictionary(int recyclingLimit)
参数
类型 | 名称 | 描述 |
---|---|---|
int | recyclingLimit | 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. 2:设置成0不控制数量,全部缓存 |
方法
| 编辑本文 查看源代码Add(TKey, TSortedKey, TValue)
向字典中添加一个值,关联到指定的外部键和排序键。
声明
public void Add(TKey key, TSortedKey sortedKey, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要关联值的外部键。 |
TSortedKey | sortedKey | 要关联值的排序键。 |
TValue | value | 要添加的值。 |
Clear()
清空字典以及内部排序字典缓存队列,释放所有资源。
声明
protected void Clear()
Contains(TKey)
检查字典是否包含指定的外部键。
声明
public bool Contains(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要检查的外部键。 |
返回
类型 | 描述 |
---|---|
bool | 如果字典包含指定的外部键,则为 true;否则为 false。 |
Contains(TKey, TSortedKey)
检查字典是否包含指定的外部键和排序键。
声明
public bool Contains(TKey key, TSortedKey sortedKey)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要检查的外部键。 |
TSortedKey | sortedKey | 要检查的排序键。 |
返回
类型 | 描述 |
---|---|
bool | 如果字典包含指定的外部键和排序键,则为 true;否则为 false。 |
RemoveKey(TKey)
从字典中移除指定外部键及其关联的所有值。
声明
public bool RemoveKey(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要移除的外部键。 |
返回
类型 | 描述 |
---|---|
bool | 如果成功移除外部键及其关联的所有值,则为 true;否则为 false。 |
RemoveSortedKey(TKey, TSortedKey)
从字典中移除指定外部键和排序键关联的值。
声明
public bool RemoveSortedKey(TKey key, TSortedKey sortedKey)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要移除值的外部键。 |
TSortedKey | sortedKey | 要移除值的排序键。 |
返回
类型 | 描述 |
---|---|
bool | 如果成功移除值,则为 true;否则为 false。 |
TryGetValue(TKey, out SortedDictionary<TSortedKey, TValue>)
尝试从字典中获取指定外部键对应的内部排序字典。
声明
public bool TryGetValue(TKey key, out SortedDictionary<TSortedKey, TValue> dic)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要获取内部排序字典的外部键。 |
SortedDictionary<TSortedKey, TValue> | dic | 获取到的内部排序字典,如果找不到则为 null。 |
返回
类型 | 描述 |
---|---|
bool | 如果找到内部排序字典,则为 true;否则为 false。 |
TryGetValueBySortedKey(TKey, TSortedKey, out TValue)
尝试从字典中获取指定外部键和排序键对应的值。
声明
public bool TryGetValueBySortedKey(TKey key, TSortedKey sortedKey, out TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要获取值的外部键。 |
TSortedKey | sortedKey | 要获取值的排序键。 |
TValue | value | 获取到的值,如果找不到则为 default。 |
返回
类型 | 描述 |
---|---|
bool | 如果找到值,则为 true;否则为 false。 |