80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using Lookup.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace Lookup.Memory;
|
|
|
|
/// <summary>
|
|
/// <see cref="ILookup{TKey,TValue}"/>
|
|
/// implementation, storing weakly-referenced <typeparamref name="TValue"/>s in <see cref="ICollection{T}"/>s
|
|
/// </summary>
|
|
/// <typeparam name="TKey">Type of the key referencing the <typeparamref name="TValue"/>s</typeparam>
|
|
/// <typeparam name="TValue">Type of the stored values, referenced by <typeparamref name="TKey"/></typeparam>
|
|
public class WeakReferenceMemoryLookup<TKey, TValue>
|
|
: MemoryLookup<TKey, WeakReference<TValue>>
|
|
where TKey : notnull
|
|
where TValue : class
|
|
{
|
|
#region Constructors
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup()
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(
|
|
IDictionary<TKey, ICollection<WeakReference<TValue>>> dictionary
|
|
) : base(dictionary)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(
|
|
IDictionary<TKey, ICollection<WeakReference<TValue>>> dictionary,
|
|
IEqualityComparer<TKey>? comparer
|
|
) : base(dictionary, comparer)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(
|
|
IEnumerable<KeyValuePair<TKey, ICollection<WeakReference<TValue>>>> collection
|
|
) : base(collection)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(
|
|
IEnumerable<KeyValuePair<TKey, ICollection<WeakReference<TValue>>>> collection,
|
|
IEqualityComparer<TKey>? comparer
|
|
) : base(collection, comparer)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(IEqualityComparer<TKey>? comparer) : base(comparer)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(int capacity) : base(capacity)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(int capacity, IEqualityComparer<TKey>? comparer) : base(capacity,
|
|
comparer)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public WeakReferenceMemoryLookup(SerializationInfo info, StreamingContext context) : base(info,
|
|
context)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
}
|