OneToManyHashSet<TKey, TValue> 类
一对多哈希集合(OneToManyHashSet),用于创建和管理键对应多个值的集合。
继承成员
命名空间: Fantasy.DataStructure.Collection
程序集: Fantasy.Net.dll
语法
public class OneToManyHashSet<TKey, TValue> : Dictionary<TKey, HashSet<TValue>>, IDictionary<TKey, HashSet<TValue>>, ICollection<KeyValuePair<TKey, HashSet<TValue>>>, IReadOnlyDictionary<TKey, HashSet<TValue>>, IReadOnlyCollection<KeyValuePair<TKey, HashSet<TValue>>>, IEnumerable<KeyValuePair<TKey, HashSet<TValue>>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable where TKey : notnull
类型参数
名称 | 描述 |
---|---|
TKey | 键的类型。 |
TValue | 值的类型。 |
构造函数
| 编辑本文 查看源代码OneToManyHashSet()
初始化 OneToManyHashSet<TKey, TValue> 类的新实例。
声明
public OneToManyHashSet()
OneToManyHashSet(int)
设置最大缓存数量
声明
public OneToManyHashSet(int recyclingLimit)
参数
类型 | 名称 | 描述 |
---|---|---|
int | recyclingLimit | 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. 2:设置成0不控制数量,全部缓存 |
方法
| 编辑本文 查看源代码Add(TKey, TValue)
添加指定的键值对到集合中。
声明
public void Add(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 键。 |
TValue | value | 值。 |
Clear()
清空集合中的数据并和队列。
声明
protected void Clear()
Contains(TKey, TValue)
判断指定的键值对是否存在于集合中。
声明
public bool Contains(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 键。 |
TValue | value | 值。 |
返回
类型 | 描述 |
---|---|
bool | 如果存在则为 true,否则为 false。 |
GetValue(TKey)
获取指定键对应的值集合,如果不存在则返回一个空的哈希集合。
声明
public HashSet<TValue> GetValue(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 键。 |
返回
类型 | 描述 |
---|---|
HashSet<TValue> | 对应的值集合或空的哈希集合。 |
RemoveKey(TKey)
从集合中移除指定键及其对应的值集合。
声明
public void RemoveKey(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 键。 |
RemoveValue(TKey, TValue)
从集合中移除指定键对应的值。
声明
public void RemoveValue(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 键。 |
TValue | value | 要移除的值。 |