public IColumns Add(Column 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 HashSetColumns(); foreach (var column in this) { result.Add(column); } result.Add(value); return(result); } }
public IColumns Remove(Column 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 HashSetColumns(); foreach (var element in this) { if (element != value) { result.Add(element); } } return(result); }