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

com.gs.collections.api.map.MutableMap Maven / Gradle / Ivy

/*
 * Copyright 2015 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.map;

import com.gs.collections.api.bag.MutableBag;
import com.gs.collections.api.bag.primitive.MutableBooleanBag;
import com.gs.collections.api.bag.primitive.MutableByteBag;
import com.gs.collections.api.bag.primitive.MutableCharBag;
import com.gs.collections.api.bag.primitive.MutableDoubleBag;
import com.gs.collections.api.bag.primitive.MutableFloatBag;
import com.gs.collections.api.bag.primitive.MutableIntBag;
import com.gs.collections.api.bag.primitive.MutableLongBag;
import com.gs.collections.api.bag.primitive.MutableShortBag;
import com.gs.collections.api.block.function.Function;
import com.gs.collections.api.block.function.Function0;
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.block.procedure.Procedure;
import com.gs.collections.api.block.procedure.Procedure2;
import com.gs.collections.api.multimap.bag.MutableBagMultimap;
import com.gs.collections.api.multimap.set.MutableSetMultimap;
import com.gs.collections.api.ordered.OrderedIterable;
import com.gs.collections.api.partition.bag.PartitionMutableBag;
import com.gs.collections.api.set.MutableSet;
import com.gs.collections.api.tuple.Pair;

/**
 * A MutableMap is similar to a JCF Map but adds additional useful internal iterator methods. The MutableMap interface
 * additionally implements some of the methods in the Smalltalk Dictionary protocol.
 */
public interface MutableMap
        extends MutableMapIterable, UnsortedMapIterable, Cloneable
{
    /**
     * Adds all the entries derived from {@code iterable} to {@code this}. The key and value for each entry
     * is determined by applying the {@code keyFunction} and {@code valueFunction} to each item in
     * {@code collection}. Any entry in {@code map} that has the same key as an entry in {@code this}
     * will have its value replaced by that in {@code map}.
     */
     MutableMap collectKeysAndValues(
            Iterable iterable,
            Function keyFunction,
            Function valueFunction);

    MutableMap newEmpty();

    MutableMap clone();

    MutableMap asUnmodifiable();

    MutableMap asSynchronized();

    MutableSetMultimap flip();

    MutableMap select(Predicate2 predicate);

    MutableMap reject(Predicate2 predicate);

     MutableMap collectValues(Function2 function);

     MutableMap collect(Function2> function);

    MutableMap tap(Procedure procedure);

    MutableBag select(Predicate predicate);

    

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

MutableBag rejectWith(Predicate2 predicate, P parameter); PartitionMutableBag partition(Predicate predicate);

PartitionMutableBag partitionWith(Predicate2 predicate, P parameter); MutableBag selectInstancesOf(Class clazz); MutableBag collect(Function function); MutableBag collectWith(Function2 function, P parameter); MutableBooleanBag collectBoolean(BooleanFunction booleanFunction); MutableByteBag collectByte(ByteFunction byteFunction); MutableCharBag collectChar(CharFunction charFunction); MutableDoubleBag collectDouble(DoubleFunction doubleFunction); MutableFloatBag collectFloat(FloatFunction floatFunction); MutableIntBag collectInt(IntFunction intFunction); MutableLongBag collectLong(LongFunction longFunction); MutableShortBag collectShort(ShortFunction shortFunction); MutableBag collectIf(Predicate predicate, Function function); MutableBag flatCollect(Function> function); /** * @deprecated in 6.0. Use {@link OrderedIterable#zip(Iterable)} instead. */ @Deprecated MutableBag> zip(Iterable that); /** * @deprecated in 6.0. Use {@link OrderedIterable#zipWithIndex()} instead. */ @Deprecated MutableSet> zipWithIndex(); MutableBagMultimap groupBy(Function function); MutableBagMultimap groupByEach(Function> function); MutableMap groupByUniqueKey(Function function); MutableMap aggregateInPlaceBy( Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator); MutableMap aggregateBy( Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator); MutableMap flipUniqueValues(); MutableMap withKeyValue(K key, V value); MutableMap withAllKeyValues(Iterable> keyValues); MutableMap withAllKeyValueArguments(Pair... keyValuePairs); MutableMap withoutKey(K key); MutableMap withoutAllKeys(Iterable keys); }