private INode <T> FindExistingNodeByKey(TKey key) { return(RWLock.GetReadLock(_lock, LockTimeout, delegate { WeakReference value; return (INode <T>)(index.TryGetValue(key, out value) ? value.Target : null); })); }
private INode GetNode(TKey key) { return(RWLock.GetReadLock(_lock, _lockTimeout, delegate { WeakReference value; return (INode)(_index.TryGetValue(key, out value) ? value.Target : null); })); }
/// <summary> /// Gets the TValue with the specified key. /// </summary> /// <value></value> public virtual TValue this[TKey key] { get { return(RWLock.GetReadLock( _dictLock, RWLock.DEFAULT_RWLOCK_TIMEOUT, () => { TValue value; if (_dict.TryGetValue(key, out value)) { return value; } return default(TValue); })); } }
/// <summary> /// Gets or sets the TValue with the specified key. /// </summary> /// <value></value> public TValue this[TKey key] { get { return(RWLock.GetReadLock(_lock, _lockTimeout, delegate { Node node; if (_data.TryGetValue(key, out node)) { DeleteNode(node); InsertNode(node); return node.Value; } return default(TValue); })); } set { Add(key, value); } }