net.sourceforge.nite.util
Class Map2D

java.lang.Object
  extended by net.sourceforge.nite.util.Map2D

public class Map2D
extends java.lang.Object

This class is used to store Objects in a map with 2 keys, used very heavily in the TimespanAnalyser. For each combination of 2 (ordered) keys, one entry can exist, just as with the usual Map. So, this is something like a very inefficient matrix, bad for performance, good for flexible construction and access. Width and height information is not really correct: width returns the number of keys that have been used as columnkeys, even if some of those keys are no longer in use. (and the same for height). Only if you call clear() will this information be flushed and will w/h again be 0/0. But then your matrix is empty :) Too bad, but since I don't need the correct w/h information now, I'm not going to fix it. Anybody feels like, go ahead!

Author:
Dennis Reidsma, UTwente

Constructor Summary
Map2D()
           
 
Method Summary
 void clear()
           
 java.util.Set columnKeySet()
          returns all columnkeys in the tree
 boolean containsRowKey(java.lang.String key)
           
 java.lang.String dumpToString()
          For debug: dump the matrix to text.
 java.lang.Object get(java.lang.Object rowKey, java.lang.Object columnKey)
          returns the value in the Map2D for the given two keys.
 int height()
           
 java.lang.Object put(java.lang.Object rowKey, java.lang.Object columnKey, java.lang.Object value)
          Add a value to the Map2D for the given two keys.
 java.lang.Object remove(java.lang.Object rowKey, java.lang.Object columnKey)
          Removes all entries for the given key
 void removeRow(java.lang.Object rowKey)
          Removes all entries in the given row
 java.util.Set rowKeySet()
          returns all rowkeys in the tree
 int width()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map2D

public Map2D()
Method Detail

put

public java.lang.Object put(java.lang.Object rowKey,
                            java.lang.Object columnKey,
                            java.lang.Object value)
Add a value to the Map2D for the given two keys. If an entry already existed for the given keys, it is returned.


get

public java.lang.Object get(java.lang.Object rowKey,
                            java.lang.Object columnKey)
returns the value in the Map2D for the given two keys.


clear

public void clear()

rowKeySet

public java.util.Set rowKeySet()
returns all rowkeys in the tree


columnKeySet

public java.util.Set columnKeySet()
returns all columnkeys in the tree


containsRowKey

public boolean containsRowKey(java.lang.String key)
Returns:
boolean true iff the tree contains the specified rowkey

remove

public java.lang.Object remove(java.lang.Object rowKey,
                               java.lang.Object columnKey)
Removes all entries for the given key


removeRow

public void removeRow(java.lang.Object rowKey)
Removes all entries in the given row


width

public int width()
Returns:
w

height

public int height()
Returns:
h

dumpToString

public java.lang.String dumpToString()
For debug: dump the matrix to text.