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

org.eclipse.collections.impl.multimap.bag.MultiReaderHashBagMultimap Maven / Gradle / Ivy

There is a newer version: 12.0.0.M3
Show newest version
/*
 * Copyright (c) 2016 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.impl.multimap.bag;

import java.io.Externalizable;

import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.multimap.Multimap;
import org.eclipse.collections.api.multimap.bag.MutableBagMultimap;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.bag.mutable.MultiReaderHashBag;
import org.eclipse.collections.impl.map.mutable.ConcurrentHashMap;
import org.eclipse.collections.impl.utility.Iterate;

public final class MultiReaderHashBagMultimap
        extends AbstractMutableBagMultimap implements Externalizable
{
    private static final long serialVersionUID = 2L;

    public MultiReaderHashBagMultimap()
    {
    }

    public MultiReaderHashBagMultimap(Multimap multimap)
    {
        super(Math.max(multimap.keysView().size() * 2, 16));
        this.putAll(multimap);
    }

    public MultiReaderHashBagMultimap(Pair... pairs)
    {
        super(pairs);
    }

    public MultiReaderHashBagMultimap(Iterable> inputIterable)
    {
        super(inputIterable);
    }

    public static  MultiReaderHashBagMultimap newMultimap()
    {
        return new MultiReaderHashBagMultimap<>();
    }

    public static  MultiReaderHashBagMultimap newMultimap(Multimap multimap)
    {
        return new MultiReaderHashBagMultimap<>(multimap);
    }

    public static  MultiReaderHashBagMultimap newMultimap(Pair... pairs)
    {
        return new MultiReaderHashBagMultimap<>(pairs);
    }

    public static  MultiReaderHashBagMultimap newMultimap(Iterable> inputIterable)
    {
        return new MultiReaderHashBagMultimap<>(inputIterable);
    }

    @Override
    protected MutableMap> createMap()
    {
        return ConcurrentHashMap.newMap();
    }

    @Override
    protected MutableMap> createMapWithKeyCount(int keyCount)
    {
        return ConcurrentHashMap.newMap(keyCount);
    }

    @Override
    protected MutableBag createCollection()
    {
        return MultiReaderHashBag.newBag();
    }

    @Override
    public MultiReaderHashBagMultimap newEmpty()
    {
        return new MultiReaderHashBagMultimap<>();
    }

    @Override
    public MutableBagMultimap flip()
    {
        return Iterate.flip(this);
    }

    @Override
    public  MultiReaderHashBagMultimap collectValues(Function function)
    {
        return this.collectValues(function, MultiReaderHashBagMultimap.newMultimap());
    }

    @Override
    public MultiReaderHashBagMultimap selectKeysValues(Predicate2 predicate)
    {
        return this.selectKeysValues(predicate, this.newEmpty());
    }

    @Override
    public MultiReaderHashBagMultimap rejectKeysValues(Predicate2 predicate)
    {
        return this.rejectKeysValues(predicate, this.newEmpty());
    }

    @Override
    public MultiReaderHashBagMultimap selectKeysMultiValues(Predicate2> predicate)
    {
        return this.selectKeysMultiValues(predicate, this.newEmpty());
    }

    @Override
    public MultiReaderHashBagMultimap rejectKeysMultiValues(Predicate2> predicate)
    {
        return this.rejectKeysMultiValues(predicate, this.newEmpty());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy