Holger's
Java API

com.antelmann.math
Class DataMap<T>

java.lang.Object
  extended by com.antelmann.math.DataMap<T>
Type Parameters:
T - the category type that is supported by this data map
All Implemented Interfaces:
Serializable, Cloneable

public class DataMap<T>
extends Object
implements Serializable, Cloneable

allows to easily collect data based on a category and a number

Since:
11.07.2009, 22:15:10
Author:
Holger Antelmann
See Also:
CounterMap, DataMatrix, Serialized Form

Nested Class Summary
static class DataMap.SnapshotModel
           
 
Constructor Summary
DataMap()
           
 
Method Summary
 void add(T category, DataPoint x)
           
 void add(T category, Number n)
           
 void addAll(DataMap<T> data)
           
protected  void checkSize()
           
 void clear()
           
 DataMap<T> clone()
           
 boolean containsKey(T key)
           
 Set<T> getCategories()
           
 DataMap.SnapshotModel getSnapshotModel()
           
 ArrayList<T> getSortedKeys()
          uses the natural order or - if not applicable - a UniversalComparator
 ArrayList<T> getSortedKeys(Comparator<? super T> comp)
          provides a sorted snapshot of the keys in this data map
 DataPoint getValue(T category)
           
 DataPoint getValueForAll()
           
 Map<T,DataPoint> getView()
           
 boolean isEmpty()
           
 void limitSize(int limit)
          uses no comparator
 void limitSize(int limit, Comparator<DataPoint> dpComparator)
          uses the given limit as both: upper and lower limit
 void limitSize(int upperLimit, int lowerLimit, Comparator<DataPoint> dpComparator)
          allows to limit this data map to a given number of keys.
 void purge(int limit, Comparator<DataPoint> comparator)
           
 int size()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataMap

public DataMap()
Method Detail

clone

public DataMap<T> clone()
                 throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

add

public void add(T category,
                Number n)

add

public void add(T category,
                DataPoint x)

addAll

public void addAll(DataMap<T> data)

limitSize

public void limitSize(int limit)
uses no comparator


limitSize

public void limitSize(int limit,
                      Comparator<DataPoint> dpComparator)
uses the given limit as both: upper and lower limit


limitSize

public void limitSize(int upperLimit,
                      int lowerLimit,
                      Comparator<DataPoint> dpComparator)
allows to limit this data map to a given number of keys. Only those remain that rank first on the given comparator. WARNING: if the limit is reached the purge operation may have a significant impact on performance depending on the comparator given. If you don't want such performance hit, then do not use a comparator.

Parameters:
upperLimit - is in effect if larger than 0
lowerLimit - must be between 0 and the upperLimit; if the upper limit is reached, data is purged to the lower limit
dpComparator - the comparator to be used
See Also:
limitSize(int), UniversalComparator.reverse(Comparator), DataPoint.COUNT_COMPARATOR, DataPoint.SUM_COMPARATOR

purge

public void purge(int limit,
                  Comparator<DataPoint> comparator)

checkSize

protected void checkSize()

getSnapshotModel

public DataMap.SnapshotModel getSnapshotModel()

getCategories

public Set<T> getCategories()

getValue

public DataPoint getValue(T category)

getValueForAll

public DataPoint getValueForAll()

getSortedKeys

public ArrayList<T> getSortedKeys()
uses the natural order or - if not applicable - a UniversalComparator


getSortedKeys

public ArrayList<T> getSortedKeys(Comparator<? super T> comp)
provides a sorted snapshot of the keys in this data map

Parameters:
comp - if null and T does not implement Comparable, a UniversalComparator is used
Returns:
a sorted snapshot of the keys currently present in a newly created, independent list
See Also:
UniversalComparator.getDefaultInstance()

containsKey

public boolean containsKey(T key)

getView

public Map<T,DataPoint> getView()

clear

public void clear()

size

public int size()

isEmpty

public boolean isEmpty()


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads