org.organicdesign.fp.collections.BaseSet Maven / Gradle / Ivy
// Copyright 2017 PlanBase Inc. & Glen Peterson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.organicdesign.fp.collections;
/**
Adds copy-on-write, "fluent interface" methods to {@link UnmodSet}.
Lowest common ancestor of {@link MutableSet}, {@link ImSet}, and {@link ImSortedSet}.
*/
public interface BaseSet extends UnmodSet {
/**
Adds an element.
If the element already exists in this set, the new value overwrites the old one. If the new
element is the same as an old element (based on the address of that item in memory, not an
equals test), the old set may be returned unchanged.
@param e the element to add to this set
@return a new set with the element added (see note above about adding duplicate elements).
*/
BaseSet put(E e);
/** Returns a new set containing all the items. */
BaseSet union(Iterable extends E> iter);
// {
// return concat(iter).toImSet();
// }
/** Removes this key from the set */
BaseSet without(E key);
}