private bool Delete(Computed dependent) { lock (this) { if (_computedArray != null) { WeakArray.Remove(ref _computedArray, dependent); return(_computedArray == null); } else if (_computedHash != null) { _computedHash.Remove(dependent); if (_computedHash.Count == 0) { _computedHash = null; return(true); } return(false); } else { return(false); } } }
private bool Insert(Computed update) { lock (this) { if (_computedHash != null) { _computedHash.Add(update); return(false); } if (WeakArray.Contains(ref _computedArray, update)) { return(false); } bool first = _computedArray == null; if (WeakArray.GetCount(ref _computedArray) >= _maxArraySize) { _computedHash = new WeakHashSet <Computed>(); foreach (var item in WeakArray.Enumerate <Computed>(_computedArray)) { _computedHash.Add(item); } _computedArray = null; _computedHash.Add(update); return(false); } WeakArray.Add(ref _computedArray, update); return(first); } }