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

org.eclipse.collections.api.bimap.BiMap 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.bimap;

import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.multimap.set.SetMultimap;
import org.eclipse.collections.api.ordered.OrderedIterable;
import org.eclipse.collections.api.partition.set.PartitionUnsortedSet;
import org.eclipse.collections.api.set.SetIterable;
import org.eclipse.collections.api.tuple.Pair;

/**
 * A map that allows users to look up key-value pairs from either direction. Uniqueness is enforced on both the keys and values.
 *
 * @since 4.2
 */
public interface BiMap extends MapIterable
{
    /**
     * Returns an inversed view of this BiMap, where the associations are in the direction of this bimap's values to keys.
     */
    BiMap inverse();

    @Override
    SetMultimap flip();

    @Override
    BiMap flipUniqueValues();

    /**
     * Converts the BiMap to an ImmutableBiMap. If the bimap is immutable, it returns itself.
     */
    @Override
    ImmutableBiMap toImmutable();

    @Override
    BiMap tap(Procedure procedure);

    @Override
    BiMap select(Predicate2 predicate);

    @Override
    BiMap reject(Predicate2 predicate);

    /**
     * {@inheritDoc}
     *
     * Implementations are expected to delegate to {@link MutableBiMap#put(Object, Object)},
     * {@link ImmutableBiMap#newWithKeyValue(Object, Object)}, or equivalent, not {@link MutableBiMap#forcePut(Object, Object)}.
     *
     * @throws RuntimeException when {@code function} returns colliding keys or values.
     */
    @Override
     BiMap collect(Function2> function);

    /**
     * {@inheritDoc}
     *
     * Implementations are expected to delegate to {@link MutableBiMap#put(Object, Object)},
     * {@link ImmutableBiMap#newWithKeyValue(Object, Object)}, or equivalent, not {@link MutableBiMap#forcePut(Object, Object)}.
     *
     * @throws RuntimeException when {@code function} returns colliding values.
     */
    @Override
     BiMap collectValues(Function2 function);

    @Override
    SetIterable select(Predicate predicate);

    @Override
    

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

SetIterable rejectWith(Predicate2 predicate, P parameter); @Override PartitionUnsortedSet partition(Predicate predicate); @Override

PartitionUnsortedSet partitionWith(Predicate2 predicate, P parameter); @Override SetIterable selectInstancesOf(Class clazz); /** * @deprecated in 8.0. Use {@link OrderedIterable#zip(Iterable)} instead. */ @Override @Deprecated SetIterable> zip(Iterable that); /** * @deprecated in 8.0. Use {@link OrderedIterable#zipWithIndex()} instead. */ @Override @Deprecated SetIterable> zipWithIndex(); @Override SetMultimap groupBy(Function function); @Override SetMultimap groupByEach(Function> function); @Override BiMap groupByUniqueKey(Function function); }