Exemplo n.º 1
0
        public WeakDictionary(IEqualityComparer <TKey> comparer, int initialProbing)
        {
            _keyComparer = comparer ?? EqualityComparer <TKey> .Default;
            var needleComparer = new NeedleConversionEqualityComparer <WeakNeedle <TKey>, TKey>(_keyComparer);

            _wrapped         = new SafeDictionary <WeakNeedle <TKey>, TValue>(needleComparer, initialProbing);
            _keyCollection   = new KeyCollection <TKey, TValue>(this);
            _valueCollection = new ValueCollection <TKey, TValue>(this);
            _reservoir       = new NeedleReservoir <TKey, WeakNeedle <TKey> >(key => new WeakNeedle <TKey>(key));
        }
Exemplo n.º 2
0
 public WeakCollection(IEqualityComparer <T> comparer, bool autoRemoveDeadItems)
 {
     _maxIndex = -1;
     _comparer = comparer ?? EqualityComparer <T> .Default;
     _wrapped  = new SafeDictionary <int, TNeedle>();
     if (autoRemoveDeadItems)
     {
         RegisterForAutoRemoveDeadItemsExtracted();
     }
     else
     {
         GC.SuppressFinalize(this);
     }
 }
Exemplo n.º 3
0
        public WeakDictionary(IEqualityComparer <TKey> comparer, bool autoRemoveDeadItems, int initialProbing)
        {
            _keyComparer = comparer ?? EqualityComparer <TKey> .Default;
            var needleComparer = new NeedleConversionEqualityComparer <TNeedle, TKey>(_keyComparer);

            _wrapped = new SafeDictionary <TNeedle, TValue>(needleComparer, initialProbing);
            if (autoRemoveDeadItems)
            {
                RegisterForAutoRemoveDeadItemsExtracted();
            }
            else
            {
                GC.SuppressFinalize(this);
            }
            _keyCollection   = new KeyCollection <TKey, TValue>(this);
            _valueCollection = new ValueCollection <TKey, TValue>(this);
        }
Exemplo n.º 4
0
        public WeakCollection(IEqualityComparer <T> comparer, bool autoRemoveDeadItems, int initialProbing)
        {
            _maxIndex = -1;
#if FAT
            _comparer = comparer ?? EqualityComparerHelper <T> .Default;
#else
            _comparer = comparer ?? EqualityComparer <T> .Default;
#endif
            _wrapped = new SafeDictionary <int, TNeedle>(initialProbing);
            if (autoRemoveDeadItems)
            {
                RegisterForAutoRemoveDeadItemsExtracted();
            }
            else
            {
                GC.SuppressFinalize(this);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Removes all the elements.
 /// </summary>
 public void Clear()
 {
     _wrapped = new SafeDictionary <int, T>();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafeCollection{T}" /> class.
 /// </summary>
 /// <param name="comparer">The value comparer.</param>
 public SafeCollection(IEqualityComparer <T> comparer)
 {
     _maxIndex = -1;
     _comparer = comparer ?? EqualityComparer <T> .Default;
     _wrapped  = new SafeDictionary <int, T>();
 }