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

org.eclipse.collections.api.bag.MutableBag Maven / Gradle / Ivy

There is a newer version: 12.0.0.M3
Show newest version
/*
 * Copyright (c) 2015 Goldman Sachs.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v. 1.0 which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 */

package org.eclipse.collections.api.bag;

import org.eclipse.collections.api.bag.primitive.MutableBooleanBag;
import org.eclipse.collections.api.bag.primitive.MutableByteBag;
import org.eclipse.collections.api.bag.primitive.MutableCharBag;
import org.eclipse.collections.api.bag.primitive.MutableDoubleBag;
import org.eclipse.collections.api.bag.primitive.MutableFloatBag;
import org.eclipse.collections.api.bag.primitive.MutableIntBag;
import org.eclipse.collections.api.bag.primitive.MutableLongBag;
import org.eclipse.collections.api.bag.primitive.MutableShortBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.BooleanFunction;
import org.eclipse.collections.api.block.function.primitive.ByteFunction;
import org.eclipse.collections.api.block.function.primitive.CharFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.ShortFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.predicate.primitive.IntPredicate;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.multimap.bag.MutableBagMultimap;
import org.eclipse.collections.api.ordered.OrderedIterable;
import org.eclipse.collections.api.partition.bag.PartitionMutableBag;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.tuple.Pair;

/**
 * A MutableBag is a Collection whose elements are unordered and may contain duplicate entries.  It varies from
 * MutableCollection in that it adds a protocol for determining, adding, and removing the number of occurrences for an
 * item.
 *
 * @since 1.0
 */
public interface MutableBag
        extends UnsortedBag, MutableBagIterable
{
    MutableMap toMapOfItemToCount();

    MutableBag selectByOccurrences(IntPredicate predicate);

    MutableBag with(T element);

    MutableBag without(T element);

    MutableBag withAll(Iterable elements);

    MutableBag withoutAll(Iterable elements);

    MutableBag newEmpty();

    MutableBag asUnmodifiable();

    MutableBag asSynchronized();

    PartitionMutableBag partition(Predicate predicate);

    

PartitionMutableBag partitionWith(Predicate2 predicate, P parameter); MutableBagMultimap groupBy(Function function); MutableBagMultimap groupByEach(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(); MutableBag tap(Procedure procedure); MutableBag select(Predicate predicate);

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

MutableBag rejectWith(Predicate2 predicate, P parameter); MutableBag selectInstancesOf(Class clazz); MutableBag collect(Function function); MutableByteBag collectByte(ByteFunction byteFunction); MutableCharBag collectChar(CharFunction charFunction); MutableIntBag collectInt(IntFunction intFunction); MutableBooleanBag collectBoolean(BooleanFunction booleanFunction); MutableDoubleBag collectDouble(DoubleFunction doubleFunction); MutableFloatBag collectFloat(FloatFunction floatFunction); MutableLongBag collectLong(LongFunction longFunction); MutableShortBag collectShort(ShortFunction shortFunction); MutableBag collectWith(Function2 function, P parameter); MutableBag collectIf(Predicate predicate, Function function); MutableBag flatCollect(Function> function); }