JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.alsUtility
Class KeyCounter

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended bygov.nasa.alsUtility.KeyCounter
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class KeyCounter
extends java.util.Hashtable
implements java.io.Serializable

used to count the number of several different kinds of objects. The different kinds are represented by different keys. Uses integer objects for counting.

See Also:
integer, Serialized Form

Constructor Summary
KeyCounter()
           
 
Method Summary
 void add(java.lang.Object key)
          add to key's count
 void add(java.lang.Object key, java.math.BigInteger count)
           
 void add(java.lang.Object key, int count)
           
 void addKeyCounter(KeyCounter other)
           
 java.math.BigInteger getCount(java.lang.Object key)
           
protected  int getIntCount(java.lang.Object key)
          For testint only.
 java.lang.Object put(java.lang.Object key, java.lang.Object element)
          overrides Hashtable.put to insure that the element is always a integer object
 double tanimotoDistance(KeyCounter other)
          BUG: only works for counts that fit in an int.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyCounter

public KeyCounter()
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object element)
overrides Hashtable.put to insure that the element is always a integer object

Specified by:
put in interface java.util.Map
See Also:
integer

add

public void add(java.lang.Object key)
add to key's count


add

public void add(java.lang.Object key,
                int count)

add

public void add(java.lang.Object key,
                java.math.BigInteger count)

addKeyCounter

public void addKeyCounter(KeyCounter other)

getCount

public java.math.BigInteger getCount(java.lang.Object key)
Returns:
the number of times key was added

getIntCount

protected int getIntCount(java.lang.Object key)
For testint only. Don't use if counts can be greater than an int can hold


tanimotoDistance

public double tanimotoDistance(KeyCounter other)
BUG: only works for counts that fit in an int.

Returns:
the Tanimoto distance to other
See Also:
Tanimoto

toString

public java.lang.String toString()

JavaGenes, NASA Ames. Written largely by Al Globus