/// <summary> /// Initializes a new instance of the <see cref="WeakKeyReference{T}"/> class. /// </summary> /// <param name="key">The key.</param> /// <param name="comparer">The comparer.</param> public WeakKeyReference(T key, WeakKeyComparer <T> comparer) : base(key) { // retain the object's hash code immediately so that even // if the target is GC'ed we will be able to find and // remove the dead weak reference. this.HashCode = comparer.GetHashCode(key); }
/// <summary> /// Initializes a new instance of the <see cref="WeakKeyDictionary{TKey, TValue}"/> class. /// </summary> /// <param name="capacity">The capacity.</param> /// <param name="comparer">The comparer.</param> public WeakKeyDictionary(int capacity, IEqualityComparer <TKey> comparer) { this.comparer = new WeakKeyComparer <TKey>(comparer); this.dictionary = new Dictionary <object, TValue>(capacity, this.comparer); }
/// <summary> /// Initializes a new instance of the <see cref="WeakDictionary{TKey, TValue}"/> class. /// </summary> /// <param name="capacity">The capacity.</param> /// <param name="comparer">The comparer.</param> public WeakDictionary(int capacity, IEqualityComparer <TKey> comparer) { this.comparer = new WeakKeyComparer <TKey>(comparer); this.dictionary = new Dictionary <object, LogoFX.Core.WeakReference <TValue> >(capacity, this.comparer); }