UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.collection
Class SortedValueNumMap

java.lang.Object
  |
  +--edu.berkeley.guir.lib.collection.SortedValueMap
        |
        +--edu.berkeley.guir.lib.collection.SortedValueNumMap
Direct Known Subclasses:
Classification

public class SortedValueNumMap
extends SortedValueMap

A Map with any kind of uniquely named Keys with numerical Values, sorted by the values (not by keys). You can set whether the Map is sorted ascending or descending, whether each value has a threshold max value or not, and whether the sum of the values has a threshold max value or not.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Jun 16 1997, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.2
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
(jasonh@cs.berkeley.edu)

Constructor Summary
SortedValueNumMap()
           
 
Method Summary
static void main(String[] argv)
           
 void put(Object key, double num)
          Convenience method, puts number in as a Double object.
 void put(Object key, float num)
          Convenience method, puts number in as a Double object.
 void put(Object key, int num)
          Convenience method, puts number in as a Double object.
 void put(Object key, Number num)
          Add a key and its value.
 void setAscending(boolean flag)
          Use this BEFORE you stick in items.
static void setDefaultAscending(boolean flag)
          Set the default value for ascending or descending order.
static void setDefaultSumThreshold(double d)
          Set the default sum threshold value.
static void setDefaultThreshold(double d)
          Set the default threshold value.
static void setDefaultUseSumThreshold(boolean flag)
          Set whether or not new SortedValueNumMaps should use the sum threshold value or not by default.
static void setDefaultUseThreshold(boolean flag)
          Set whether or not new SortedValueNumMaps should use the threshold value or not by default.
 void setSumThreshold(double d)
          Set the threshold value for this SortedValueNumMap.
 void setThreshold(double d)
          Set the threshold value for this SortedValueNumMap.
 void setUseSumThreshold(boolean flag)
          Use the current sum threshold value, or just ignore checking the sum?
 void setUseThreshold(boolean flag)
          Use the current threshold value, or just ignore checking values?
 
Methods inherited from class edu.berkeley.guir.lib.collection.SortedValueMap
clear, containsKey, containsValue, entrySet, equals, get, getFirstKey, getFirstValue, getLargestKey, getLargestValue, getLastKey, getLastValue, getSmallestKey, getSmallestValue, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortedValueNumMap

public SortedValueNumMap()
Method Detail

setAscending

public void setAscending(boolean flag)
Use this BEFORE you stick in items.
Overrides:
setAscending in class SortedValueMap
Parameters:
flag - is true if ascending order, false if descending.

setThreshold

public void setThreshold(double d)
Set the threshold value for this SortedValueNumMap. Values added to this SortedValueNumMap cannot exceed this value.
Parameters:
d - is the threshold value to set to.

setUseThreshold

public void setUseThreshold(boolean flag)
Use the current threshold value, or just ignore checking values?
Parameters:
flag - is true if we should check values against the threshold, otherwise false.

setSumThreshold

public void setSumThreshold(double d)
Set the threshold value for this SortedValueNumMap. The sum of values added to this SortedValueNumMap cannot exceed this value.
Parameters:
d - is the threshold sum value to set to.

setUseSumThreshold

public void setUseSumThreshold(boolean flag)
Use the current sum threshold value, or just ignore checking the sum?
Parameters:
flag - is true if we should check sums against the sum threshold, otherwise false.

setDefaultAscending

public static void setDefaultAscending(boolean flag)
Set the default value for ascending or descending order. This is the sorting regime that new SortedValueNumMaps will use.
Parameters:
flag - is true if new SortedValueNumMaps should sort in ascending order, false if in descending order.

setDefaultThreshold

public static void setDefaultThreshold(double d)
Set the default threshold value. This is the threshold value that new SortedValueNumMaps will use.
Parameters:
f - is the default threshold value to set to.
See Also:
setThreshold(double)

setDefaultUseThreshold

public static void setDefaultUseThreshold(boolean flag)
Set whether or not new SortedValueNumMaps should use the threshold value or not by default. That is, will new SortedValueNumMaps use a threshold value? New SortedValueNumMaps will use the default threshold value automatically, as set by setDefaultThresholdValue().
Parameters:
flag - is true if new SortedValueNumMaps should use threshold value.
See Also:
setThreshold(double), setDefaultThreshold(double)

setDefaultSumThreshold

public static void setDefaultSumThreshold(double d)
Set the default sum threshold value. This is the sum threshold value that new SortedValueNumMaps will use.
Parameters:
d - is the default threshold value to set to.
See Also:
setSumThreshold(double)

setDefaultUseSumThreshold

public static void setDefaultUseSumThreshold(boolean flag)
Set whether or not new SortedValueNumMaps should use the sum threshold value or not by default. That is, will new SortedValueNumMaps use a sum threshold value? New SortedValueNumMaps will use the default sum threshold value automatically, as set by setSumDefaultThresholdValue().
Parameters:
flag - is true if new SortedValueNumMaps should use threshold value.
See Also:
setSumThreshold(double), setDefaultSumThreshold(double)

put

public void put(Object key,
                int num)
Convenience method, puts number in as a Double object.

put

public void put(Object key,
                float num)
Convenience method, puts number in as a Double object.

put

public void put(Object key,
                double num)
Convenience method, puts number in as a Double object.

put

public void put(Object key,
                Number num)
Add a key and its value. Convenience method, puts number in as a Double object.
Parameters:
key - is the name of the key. if the key already exists, this will overwrite the previous value.
value - is the value. Ensures that the value and the sum of the values does not exceed threshold.
Throws:
NumberFormatException - if the value or the sum exceeds sumThreshold.
IllegalArgumentException - if the same name is added more than once.

main

public static void main(String[] argv)

Copyright Information