OneToManyList<TKey, TValue> 类
一对多关系的列表字典。
继承成员
命名空间: Fantasy.DataStructure.Collection
程序集: Fantasy.Net.dll
语法
public class OneToManyList<TKey, TValue> : Dictionary<TKey, List<TValue>>, IDictionary<TKey, List<TValue>>, ICollection<KeyValuePair<TKey, List<TValue>>>, IReadOnlyDictionary<TKey, List<TValue>>, IReadOnlyCollection<KeyValuePair<TKey, List<TValue>>>, IEnumerable<KeyValuePair<TKey, List<TValue>>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable where TKey : notnull
类型参数
名称 | 描述 |
---|---|
TKey | 键的类型。 |
TValue | 值的类型。 |
构造函数
| 编辑本文 查看源代码OneToManyList()
初始化一个新的 OneToManyList<TKey, TValue> 实例。
声明
public OneToManyList()
OneToManyList(int)
设置最大缓存数量
声明
public OneToManyList(int recyclingLimit)
参数
类型 | 名称 | 描述 |
---|---|---|
int | recyclingLimit | 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. 2:设置成0不控制数量,全部缓存 |
方法
| 编辑本文 查看源代码Add(TKey, TValue)
向列表中添加指定键和值。
声明
public void Add(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要添加值的键。 |
TValue | value | 要添加的值。 |
Clear()
清除字典中的所有键值对,并回收相关的值集合。
声明
public void Clear()
Contains(TKey, TValue)
判断给定的键和值是否存在于列表中。
声明
public bool Contains(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要搜索的键。 |
TValue | value | 要搜索的值。 |
返回
类型 | 描述 |
---|---|
bool |
First(TKey)
获取指定键对应的列表中的第一个值。
声明
public TValue First(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要获取值的键。 |
返回
类型 | 描述 |
---|---|
TValue | 键对应的列表中的第一个值。 |
GetValues(TKey)
获取指定键关联的所有值的列表。
声明
public List<TValue> GetValues(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要获取值的键。 |
返回
类型 | 描述 |
---|---|
List<TValue> | 键关联的所有值的列表。 |
RemoveByKey(TKey)
从列表中移除指定键及其关联的所有值。
声明
public bool RemoveByKey(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要移除的键。 |
返回
类型 | 描述 |
---|---|
bool |
RemoveValue(TKey, TValue)
从列表中移除指定键和值。
声明
public bool RemoveValue(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要移除值的键。 |
TValue | value | 要移除的值。 |
返回
类型 | 描述 |
---|---|
bool |