mro.util.doublehashmap
Class DoubleHashMap

java.lang.Object
  extended by mro.util.doublehashmap.DoubleHashMap

public class DoubleHashMap
extends java.lang.Object

A DoubleHashMap has two indexes. There is only one copy of each index value.


Field Summary
private  java.util.HashSet firstIndexSet
           
private  java.util.HashMap firstMap
           
private  java.util.HashSet secondIndexSet
           
private  java.util.HashMap secondMap
           
private  int size
           
 
Constructor Summary
DoubleHashMap()
           
 
Method Summary
 java.lang.Object get(java.lang.Object first, java.lang.Object second)
          Returns the Object that was indexed with "first" and "second".
 void invert()
          Inverts the mapping, so the fist index becomes the second.
 java.util.Set keySetOfSecondIndexForElementInFirst(java.lang.Object first)
           
 void put(java.lang.Object first, java.lang.Object second, java.lang.Object value)
          Adds a Object "value" indexed with the Object:s "first" and "second"
private  void putIntoMap(java.lang.Object o1, java.lang.Object o2, java.lang.Object value, java.util.HashMap map)
          Convenience method, for putting objects into a HashMap of HashMap:s.
 java.lang.Object remove(java.lang.Object first, java.lang.Object second)
          Removes the Object with the indexes.
 void removeAllFirst(java.lang.Object first)
          Removes all Objects with the specified "first" index.
 void removeAllSecond(java.lang.Object second)
          Removes all Objects with the specified "second" index.
private  java.lang.Object removeFromMap(java.lang.Object o1, java.lang.Object o2, java.util.HashMap map)
          Convenience method, for removing objects in a HashMap of HashMap:s.
 int size()
           
 int sizeOfFirstIndex()
           
 int sizeOfSecondIndex()
           
 int sizeOfSecondIndexForElementInFirst(java.lang.Object first)
           
 java.util.Vector values()
          Returns all Objects in the DoubleHashMap as a Vector.
 java.util.Vector valuesForFirstIndex(java.lang.Object first)
          Returns a Vector of those value Objects that are stored with the specified "first" index.
 java.util.Vector valuesForSecondIndex(java.lang.Object second)
          Returns a Vector of those value Objects that are stored with the specified "second" index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstIndexSet

private java.util.HashSet firstIndexSet

secondIndexSet

private java.util.HashSet secondIndexSet

firstMap

private java.util.HashMap firstMap

secondMap

private java.util.HashMap secondMap

size

private int size
Constructor Detail

DoubleHashMap

public DoubleHashMap()
Method Detail

put

public void put(java.lang.Object first,
                java.lang.Object second,
                java.lang.Object value)
Adds a Object "value" indexed with the Object:s "first" and "second"

Parameters:
first -
second -
value -

putIntoMap

private void putIntoMap(java.lang.Object o1,
                        java.lang.Object o2,
                        java.lang.Object value,
                        java.util.HashMap map)
Convenience method, for putting objects into a HashMap of HashMap:s.


get

public java.lang.Object get(java.lang.Object first,
                            java.lang.Object second)
Returns the Object that was indexed with "first" and "second".

Parameters:
first -
second -
Returns:
an Object

remove

public java.lang.Object remove(java.lang.Object first,
                               java.lang.Object second)
Removes the Object with the indexes.

Parameters:
first -
second -
Returns:
an Object

removeFromMap

private java.lang.Object removeFromMap(java.lang.Object o1,
                                       java.lang.Object o2,
                                       java.util.HashMap map)
Convenience method, for removing objects in a HashMap of HashMap:s.


removeAllFirst

public void removeAllFirst(java.lang.Object first)
Removes all Objects with the specified "first" index.

Parameters:
first -

removeAllSecond

public void removeAllSecond(java.lang.Object second)
Removes all Objects with the specified "second" index.

Parameters:
second -

values

public java.util.Vector values()
Returns all Objects in the DoubleHashMap as a Vector. An object is returned for each mapping, meaning that an object can appear at several positions in the Vector.

Returns:
a Vector

valuesForFirstIndex

public java.util.Vector valuesForFirstIndex(java.lang.Object first)
Returns a Vector of those value Objects that are stored with the specified "first" index.

Parameters:
first -
Returns:
a Vector

valuesForSecondIndex

public java.util.Vector valuesForSecondIndex(java.lang.Object second)
Returns a Vector of those value Objects that are stored with the specified "second" index.

Parameters:
second -
Returns:
a Vector

invert

public void invert()
Inverts the mapping, so the fist index becomes the second.


size

public int size()

sizeOfFirstIndex

public int sizeOfFirstIndex()

sizeOfSecondIndex

public int sizeOfSecondIndex()

sizeOfSecondIndexForElementInFirst

public int sizeOfSecondIndexForElementInFirst(java.lang.Object first)

keySetOfSecondIndexForElementInFirst

public java.util.Set keySetOfSecondIndexForElementInFirst(java.lang.Object first)