OneToManyQueue<TKey, TValue> 类
支持一对多关系的队列,用于存储具有相同键的值的队列集合。
继承成员
命名空间: Fantasy.DataStructure.Collection
程序集: Fantasy.Net.dll
语法
public class OneToManyQueue<TKey, TValue> : Dictionary<TKey, Queue<TValue>>, IDictionary<TKey, Queue<TValue>>, ICollection<KeyValuePair<TKey, Queue<TValue>>>, IReadOnlyDictionary<TKey, Queue<TValue>>, IReadOnlyCollection<KeyValuePair<TKey, Queue<TValue>>>, IEnumerable<KeyValuePair<TKey, Queue<TValue>>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable where TKey : notnull
类型参数
名称 | 描述 |
---|---|
TKey | 键的类型。 |
TValue | 值的类型。 |
构造函数
| 编辑本文 查看源代码OneToManyQueue(int)
创建一个 OneToManyQueue<TKey, TValue> 一对多关系的队列的实例。设置最大缓存数量
声明
public OneToManyQueue(int recyclingLimit = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
int | recyclingLimit | 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. 2:设置成0不控制数量,全部缓存 |
方法
| 编辑本文 查看源代码Clear()
清空当前实例的数据,同时回收所有值队列。
声明
protected void Clear()
Contains(TKey, TValue)
判断指定键的值队列是否包含指定的值。
声明
public bool Contains(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要查找的键。 |
TValue | value | 要查找的值。 |
返回
类型 | 描述 |
---|---|
bool | 如果存在,则为 |
Dequeue(TKey)
从指定键的值队列中出队一个值。
声明
public TValue Dequeue(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要出队的键。 |
返回
类型 | 描述 |
---|---|
TValue | 出队的值。 |
Enqueue(TKey, TValue)
将指定的值添加到指定键的值队列中。
声明
public void Enqueue(TKey key, TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要添加值的键。 |
TValue | value | 要添加的值。 |
RemoveKey(TKey)
从字典中移除指定键及其对应的值队列。
声明
public void RemoveKey(TKey key)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要移除的键。 |
TryDequeue(TKey, out TValue)
尝试从指定键的值队列中出队一个值。
声明
public bool TryDequeue(TKey key, out TValue value)
参数
类型 | 名称 | 描述 |
---|---|---|
TKey | key | 要出队的键。 |
TValue | value | 出队的值。 |
返回
类型 | 描述 |
---|---|
bool | 如果成功出队,则为 |