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

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

There is a newer version: 12.0.0.M3
Show newest version
/*
 * Copyright (c) 2018 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.RichIterable;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.primitive.ObjectIntToObjectFunction;
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.collection.MutableCollection;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MutableMapIterable;
import org.eclipse.collections.api.multimap.bag.MutableBagIterableMultimap;
import org.eclipse.collections.api.partition.bag.PartitionMutableBagIterable;
import org.eclipse.collections.api.set.MutableSetIterable;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.api.tuple.primitive.ObjectIntPair;

public interface MutableBagIterable extends Bag, MutableCollection
{
    /**
     * Add number of {@code occurrences} for an {@code item}. If the {@code item} does not exist, then the {@code item} is added to the bag.
     *
     * 

* For Example: *

     * MutableBagIterable<String> names = Bags.mutable.of("A", "B", "B");
     * Assert.assertEquals(4, names.addOccurrences("A", 3));
     * 
* * @return updated number of occurrences. * @throws IllegalArgumentException if {@code occurrences} are less than 0. */ int addOccurrences(T item, int occurrences); boolean removeOccurrences(Object item, int occurrences); boolean setOccurrences(T item, int occurrences); @Override MutableBagIterable tap(Procedure procedure); @Override MutableBagIterable select(Predicate predicate); @Override

MutableBagIterable selectWith(Predicate2 predicate, P parameter); @Override MutableBagIterable reject(Predicate predicate); @Override

MutableBagIterable rejectWith(Predicate2 predicate, P parameter); @Override PartitionMutableBagIterable partition(Predicate predicate); @Override

PartitionMutableBagIterable partitionWith(Predicate2 predicate, P parameter); @Override MutableBagIterable selectInstancesOf(Class clazz); @Override MutableBagIterableMultimap groupBy(Function function); @Override MutableBagIterableMultimap groupByEach(Function> function); @Override MutableSetIterable> zipWithIndex(); @Override MutableBagIterable selectByOccurrences(IntPredicate predicate); /** * @since 9.2 */ @Override default MutableBagIterable selectDuplicates() { return this.selectByOccurrences(occurrences -> occurrences > 1); } /** * @since 9.2 */ @Override MutableSetIterable selectUnique(); @Override MutableMapIterable toMapOfItemToCount(); /** * @since 6.0 */ @Override MutableList> topOccurrences(int count); /** * @since 6.0 */ @Override MutableList> bottomOccurrences(int count); @Override MutableBagIterable with(T element); @Override MutableBagIterable without(T element); @Override MutableBagIterable withAll(Iterable elements); @Override MutableBagIterable withoutAll(Iterable elements); @Override RichIterable collectWithOccurrences(ObjectIntToObjectFunction function); }