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 org.apache.commons.collections;
  17. import java.util.SortedMap;
  18. /**
  19. * Defines a map that allows bidirectional lookup between key and values
  20. * and retains both keys and values in sorted order.
  21. * <p>
  22. * Implementations should allow a value to be looked up from a key and
  23. * a key to be looked up from a value with equal performance.
  24. *
  25. * @since Commons Collections 3.0
  26. * @version $Revision: 1.6 $ $Date: 2004/02/18 01:15:42 $
  27. *
  28. * @author Stephen Colebourne
  29. */
  30. public interface SortedBidiMap extends OrderedBidiMap, SortedMap {
  31. /**
  32. * Gets a view of this map where the keys and values are reversed.
  33. * <p>
  34. * Changes to one map will be visible in the other and vice versa.
  35. * This enables both directions of the map to be accessed equally.
  36. * <p>
  37. * Implementations should seek to avoid creating a new object every time this
  38. * method is called. See <code>AbstractMap.values()</code> etc. Calling this
  39. * method on the inverse map should return the original.
  40. * <p>
  41. * Implementations must return a <code>SortedBidiMap</code> instance,
  42. * usually by forwarding to <code>inverseSortedBidiMap()</code>.
  43. *
  44. * @return an inverted bidirectional map
  45. */
  46. public BidiMap inverseBidiMap();
  47. /**
  48. * Gets a view of this map where the keys and values are reversed.
  49. * <p>
  50. * Changes to one map will be visible in the other and vice versa.
  51. * This enables both directions of the map to be accessed as a <code>SortedMap</code>.
  52. * <p>
  53. * Implementations should seek to avoid creating a new object every time this
  54. * method is called. See <code>AbstractMap.values()</code> etc. Calling this
  55. * method on the inverse map should return the original.
  56. * <p>
  57. * The inverse map returned by <code>inverseBidiMap()</code> should be the
  58. * same object as returned by this method.
  59. *
  60. * @return an inverted bidirectional map
  61. */
  62. public SortedBidiMap inverseSortedBidiMap();
  63. }