View Javadoc

1   /*
2    *  Copyright 2003-2004 The Apache Software Foundation
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.collections15;
17  
18  import java.util.SortedMap;
19  
20  /***
21   * Defines a map that allows bidirectional lookup between key and values and
22   * retains both keys and values in sorted order.
23   * <p/>
24   * Implementations should allow a value to be looked up from a key and a key to
25   * be looked up from a value with equal performance.
26   *
27   * @author Stephen Colebourne
28   * @version $Revision: 1.2 $ $Date: 2004/10/17 01:02:42 $
29   * @since Commons Collections 3.0
30   */
31  public interface SortedBidiMap <K, V> extends OrderedBidiMap<K, V>, SortedMap<K, V>
32  {
33  
34      /***
35       * Gets a view of this map where the keys and values are reversed.
36       * <p/>
37       * Changes to one map will be visible in the other and vice versa. This
38       * enables both directions of the map to be accessed equally.
39       * <p/>
40       * Implementations should seek to avoid creating a new object every time
41       * this method is called. See <code>AbstractMap.values()</code> etc. Calling
42       * this method on the inverse map should return the original.
43       * <p/>
44       * Implementations must return a <code>SortedBidiMap</code> instance,
45       * usually by forwarding to <code>inverseSortedBidiMap()</code>.
46       *
47       * @return an inverted bidirectional map
48       */
49      public BidiMap<V, K> inverseBidiMap();
50  
51      /***
52       * Gets a view of this map where the keys and values are reversed.
53       * <p/>
54       * Changes to one map will be visible in the other and vice versa. This
55       * enables both directions of the map to be accessed as a
56       * <code>SortedMap</code>.
57       * <p/>
58       * Implementations should seek to avoid creating a new object every time
59       * this method is called. See <code>AbstractMap.values()</code> etc. Calling
60       * this method on the inverse map should return the original.
61       * <p/>
62       * The inverse map returned by <code>inverseBidiMap()</code> should be the
63       * same object as returned by this method.
64       *
65       * @return an inverted bidirectional map
66       */
67      public SortedBidiMap<V, K> inverseSortedBidiMap();
68  
69  }