All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gs.collections.api.set.MutableSet Maven / Gradle / Ivy

Go to download

GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map implementations with a rich API and set of utility classes that work with any JDK compatible Collections, Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework.

There is a newer version: 7.0.3
Show newest version
/*
 * Copyright 2011 Goldman Sachs.
 *
 * 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 com.gs.collections.api.set;

import java.util.Set;

import com.gs.collections.api.block.function.Function;
import com.gs.collections.api.block.function.Function2;
import com.gs.collections.api.block.function.primitive.BooleanFunction;
import com.gs.collections.api.block.function.primitive.ByteFunction;
import com.gs.collections.api.block.function.primitive.CharFunction;
import com.gs.collections.api.block.function.primitive.DoubleFunction;
import com.gs.collections.api.block.function.primitive.FloatFunction;
import com.gs.collections.api.block.function.primitive.IntFunction;
import com.gs.collections.api.block.function.primitive.LongFunction;
import com.gs.collections.api.block.function.primitive.ShortFunction;
import com.gs.collections.api.block.predicate.Predicate;
import com.gs.collections.api.block.predicate.Predicate2;
import com.gs.collections.api.collection.MutableCollection;
import com.gs.collections.api.multimap.set.MutableSetMultimap;
import com.gs.collections.api.partition.set.PartitionMutableSet;
import com.gs.collections.api.set.primitive.MutableBooleanSet;
import com.gs.collections.api.set.primitive.MutableByteSet;
import com.gs.collections.api.set.primitive.MutableCharSet;
import com.gs.collections.api.set.primitive.MutableDoubleSet;
import com.gs.collections.api.set.primitive.MutableFloatSet;
import com.gs.collections.api.set.primitive.MutableIntSet;
import com.gs.collections.api.set.primitive.MutableLongSet;
import com.gs.collections.api.set.primitive.MutableShortSet;
import com.gs.collections.api.tuple.Pair;

/**
 * A MutableSet is an implementation of a JCF Set which provides methods matching the Smalltalk Collection protocol.
 */
public interface MutableSet
        extends UnsortedSetIterable, MutableCollection, Set, Cloneable
{
    MutableSet with(T element);

    MutableSet without(T element);

    MutableSet withAll(Iterable elements);

    MutableSet withoutAll(Iterable elements);

    MutableSet newEmpty();

    MutableSet clone();

    MutableSet select(Predicate predicate);

    

MutableSet selectWith(Predicate2 predicate, P parameter); MutableSet reject(Predicate predicate);

MutableSet rejectWith(Predicate2 predicate, P parameter); PartitionMutableSet partition(Predicate predicate); MutableSet selectInstancesOf(Class clazz); MutableSet collect(Function function); MutableBooleanSet collectBoolean(BooleanFunction booleanFunction); MutableByteSet collectByte(ByteFunction byteFunction); MutableCharSet collectChar(CharFunction charFunction); MutableDoubleSet collectDouble(DoubleFunction doubleFunction); MutableFloatSet collectFloat(FloatFunction floatFunction); MutableIntSet collectInt(IntFunction intFunction); MutableLongSet collectLong(LongFunction longFunction); MutableShortSet collectShort(ShortFunction shortFunction); MutableSet collectWith(Function2 function, P parameter); MutableSet collectIf(Predicate predicate, Function function); MutableSet flatCollect(Function> function); /** * Returns an unmodifable view of the set. * The returned set will be Serializable if this set is Serializable. * * @return an unmodifiable view of this set */ MutableSet asUnmodifiable(); MutableSet asSynchronized(); /** * Returns an immutable copy of this set. If the set is immutable, it returns itself. *

* The returned set will be Serializable if this set is Serializable. */ ImmutableSet toImmutable(); MutableSetMultimap groupBy(Function function); MutableSetMultimap groupByEach(Function> function); MutableSet> zip(Iterable that); MutableSet> zipWithIndex(); MutableSet union(SetIterable set); MutableSet intersect(SetIterable set); MutableSet difference(SetIterable subtrahendSet); MutableSet symmetricDifference(SetIterable setB); MutableSet> powerSet(); }