001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * https://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.collections4; 019 020import java.util.Comparator; 021import java.util.SortedMap; 022 023/** 024 * Defines a map that allows bidirectional lookup between key and values and retains both keys and values in sorted order. 025 * <p> 026 * Implementations should allow a value to be looked up from a key and a key to be looked up from a value with equal performance. 027 * </p> 028 * 029 * @param <K> The type of the keys in the map 030 * @param <V> The type of the values in the map 031 * @since 3.0 032 */ 033public interface SortedBidiMap<K, V> extends OrderedBidiMap<K, V>, SortedMap<K, V> { 034 035 /** 036 * Gets a view of this map where the keys and values are reversed. 037 * <p> 038 * Changes to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed equally. 039 * </p> 040 * <p> 041 * Implementations should seek to avoid creating a new object every time this method is called. See {@code AbstractMap.values()} etc. Calling this method on 042 * the inverse map should return the original. 043 * </p> 044 * <p> 045 * Implementations must return a {@code SortedBidiMap} instance, usually by forwarding to {@code inverseSortedBidiMap()}. 046 * </p> 047 * 048 * @return An inverted bidirectional map. 049 */ 050 @Override 051 SortedBidiMap<V, K> inverseBidiMap(); 052 053 /** 054 * Gets the comparator used for the values in the value-to-key map aspect. 055 * 056 * @return Comparator<? super V>. 057 */ 058 Comparator<? super V> valueComparator(); 059}