com.tensegrity.generic.util
Class MapReverse

java.lang.Object
  extended bycom.tensegrity.generic.util.MapReverse

public final class MapReverse
extends java.lang.Object

This class contains a method to reverse a map. The operation is only possible if all the values are distinct.

Version:
$Id: MapReverse.java,v 1.7 2003/09/12 13:47:20 AndreasEbbert Exp $
Author:
S. Rutz

Method Summary
static java.util.Map reverse(java.util.Map map)
          Reverses a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reverse

public static final java.util.Map reverse(java.util.Map map)
                                   throws MapReverseNotPossibleException
Reverses a map. A new map is allocated and the keys of the new map are the values of the input map. The associated keys of the original values become the values of the reversed map.

Please note that reversing a map is only possible if all of the values are unique (and not just the keys). If the values are not unique, the method will throw an exception.

Parameters:
map - the Map to reverse; may not be null.
Returns:
the reversed map.
Throws:
MapReverseNotPossibleException, - if the values of the input map are not distinct.
InvalidArgumentException, - if argument is null.
MapReverseNotPossibleException


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.