コード例 #1
0
 /// <summary>Initializes a new instance of the <see cref="WeakValueDictionary{TKey,TValue}" /> class.</summary>
 /// <param name="capacity">Initial capacity.</param>
 public WeakValueDictionary(int capacity)
 {
     _pool  = new RequestReturnPool <WeakReference>(capacity, () => new WeakReference(null));
     _inner = new Dictionary <TKey, WeakReference>(capacity);
     _garbageCollectionSentinel = new WeakReference(new object());
     _deadKeys = new Queue <KeyValuePair <TKey, WeakReference> >();
 }
コード例 #2
0
 private RequestReturnPool <WeakReference> GetPool()
 {
     return(_pool ?? (_pool = new RequestReturnPool <WeakReference>(_inner.Count, () => new WeakReference(null))));
 }