
org.eclipse.collections.api.bimap.BiMap Maven / Gradle / Ivy
/*
* 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.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.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();
SetMultimap flip();
BiMap flipUniqueValues();
/**
* Converts the BiMap to an ImmutableBiMap. If the bimap is immutable, it returns itself.
*/
ImmutableBiMap toImmutable();
BiMap tap(Procedure super V> procedure);
BiMap select(Predicate2 super K, ? super V> predicate);
BiMap reject(Predicate2 super K, ? super V> 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.
*/
BiMap collect(Function2 super K, ? super V, Pair> 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.
*/
BiMap collectValues(Function2 super K, ? super V, ? extends R> function);
SetIterable select(Predicate super V> predicate);
SetIterable selectWith(Predicate2 super V, ? super P> predicate, P parameter);
SetIterable reject(Predicate super V> predicate);
SetIterable rejectWith(Predicate2 super V, ? super P> predicate, P parameter);
PartitionUnsortedSet partition(Predicate super V> predicate);
PartitionUnsortedSet partitionWith(Predicate2 super V, ? super P> predicate, P parameter);
SetIterable selectInstancesOf(Class clazz);
SetIterable> zip(Iterable that);
SetIterable> zipWithIndex();
SetMultimap groupBy(Function super V, ? extends V1> function);
SetMultimap groupByEach(Function super V, ? extends Iterable> function);
BiMap groupByUniqueKey(Function super V, ? extends VV> function);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy