public IScalars Add(Scalar value) { value.VerifyNotNull(nameof(value)); if (Contains(value)) { return(this); } if (!IsSealed) { _hashSet.Add(value); return(this); } if (Count == 0) { return(value); } else { var result = new HashSetScalars(); foreach (var column in this) { result.Add(column); } result.Add(value); return(result); } }
public IScalars Remove(Scalar value) { value.VerifyNotNull(nameof(value)); if (!Contains(value)) { return(this); } if (Count == 1) { return(Empty); } if (Count == 2) { return(_hashSet.Single(x => x != value)); } if (!IsSealed) { _hashSet.Remove(value); return(this); } var result = new HashSetScalars(); foreach (var element in this) { if (element != value) { result.Add(element); } } return(result); }