/// <summary> /// Returns a new set containing every element of this set except the value given as a parameter. /// If value is not in this set, then returns this set. [Time: log(this.Count)] /// </summary> /// <param name="value">The value to be deleted.</param> /// <returns>The new set that does not contain <paramref name="value"/>.</returns> public Set <T> Remove(T value) //^ ensures !this.Contains(value) <==> ((object)this == result); // pointer equals iff value not contained //^ ensures this.Contains(value) <==> (result.Count + 1 == this.Count); { bool deleted = false; LobTree <T> /*?*/ newElems = LobTree <T> .Remove(this.elems, value, out deleted); return(deleted ? new Set <T>(count - 1, newElems) : this); }
private void InPlaceRemove(T value) { bool deleted = false; elems = LobTree <T> .Remove(elems, value, out deleted); if (deleted) { count -= 1; this.InvalidateCache(); } }
/// <summary> /// Removes the key-value pair from the map /// </summary> /*internal*/ private void InPlaceRemove(Pair <T, S> d) { bool deleted = false; this.elems = LobTree <Maplet> .Remove(elems, new Maplet(d), out deleted); this.InvalidateCache(); if (deleted) { count -= 1; } }
/// <summary> /// Removes the element with the specified key from the map /// </summary> private void InPlaceRemoveKey(T /*!*/ key) { bool deleted; this.elems = LobTree <Maplet> .Remove(elems, new Maplet(new Pair <T, S>(key, default(S))), out deleted); this.InvalidateCache(); if (deleted) { count -= 1; } }