Пример #1
0
 public void Remove(TKey key)
 {
     LockWrapper.WriteLock(_locker, Timeout, () =>
     {
         _index.Remove(key);
         return(false);
     });
 }
Пример #2
0
 public void ClearIndex()
 {
     LockWrapper.WriteLock(_locker, Timeout, () =>
     {
         _index.Clear();
         return(false);
     });
 }
Пример #3
0
            public void Add(TKey key, TItem item)
            {
                var node = _owner._lifeSpan.Add(item);

                LockWrapper.WriteLock(_locker, Timeout, () =>
                {
                    _index[key] = new WeakReference(node, false);
                    return(false);
                });
            }
Пример #4
0
 public void RemoveRange(IEnumerable <TKey> set)
 {
     LockWrapper.WriteLock(_locker, Timeout, () =>
     {
         foreach (var key in set)
         {
             _index.Remove(key);
         }
         return(false);
     });
 }
Пример #5
0
 public void AddRange(IEnumerable <KeyValuePair <TKey, TItem> > set)
 {
     LockWrapper.WriteLock(_locker, Timeout, () =>
     {
         foreach (var pair in set)
         {
             var node         = _owner._lifeSpan.Add(pair.Value);
             _index[pair.Key] = new WeakReference(node, false);
         }
         return(false);
     });
 }
Пример #6
0
            public bool AddNode(Node node)
            {
                var item = node.Value as TItem;

                if (item == null)
                {
                    return(false);
                }
                TKey key = _getKey(item);

                return(LockWrapper.WriteLock(_locker, Timeout, () =>
                {
                    bool isDup = _index.ContainsKey(key);
                    _index[key] = new WeakReference(node, false);
                    return isDup;
                }));
            }
Пример #7
0
 public int RebuildIndex()
 {
     return(LockWrapper.WriteLock(_locker, Timeout, () =>
     {
         _index.Clear();
         foreach (var node in _owner._lifeSpan)
         {
             var item = node.Value as TItem;
             if (item == null)
             {
                 continue;
             }
             TKey key = _getKey(item);
             _index[key] = new WeakReference(node, false);
         }
         return _index.Count;
     }));
 }