Holger's Java API

## com.antelmann.math
Class CounterMap<T>

    java.lang.Object
      com.antelmann.math.CounterMap<T>

All Implemented Interfaces:
  Addable<CounterMap<T>>, DetailedString, Serializable

    public class CounterMap<T>

extends Object
implements Serializable, DetailedString, Addable<CounterMap<T>>

a simple helper class that allows to easily count occurrences of categories.

Since:
  27.05.2009, 13:21:44
Author:
  Holger Antelmann
See Also:
  `DataMatrix`, `DataMap`, Serialized Form

Constructor Summary
`CounterMap()`

Method Summary
`CounterMap<T>` `add(CounterMap<T> data)` adds this instance to the other given one and returns the result; this entry itself remains untouched
`void` `add(T element)`
`void` `add(T element, int count)`
`void` `addAll(Map<? extends T,? extends Number> data)`
`void` `clear()`
`boolean` `equals(Object obj)`
`int` `getCountFor(T element)`
`DataPoint` `getCountStatistics()`
`ArrayList<T>` `getDublicates()`
`Set<T>` `getElements()`
`int` `getMaxCount()`
`int` `getMinCount()`
`double` `getPercentageFor(T element)`
`TreeSet<T>` `getSortedElements()`
`TreeSet<T>` `getSortedElements(Comparator<? super T> comp)`
`TreeSet<T>` `getSortedElementsByCount(boolean ascending)`
`int` `getTotal()`
`ArrayList<T>` `getUniques()`
`Map<T,Integer>` `getView()` provides an unmodifiable view of the data
`int` `hashCode()`
`boolean` `isEmpty()`
`int` `size()`
`String` `toDetailedString()` provides full details of this instance in a String.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CounterMap

    public CounterMap()

Method Detail

### add

    public void add(T element)

### add

    public void add(T element,
                    int count)

### addAll

    public void addAll(Map<? extends T,? extends Number> data)

### add

    public CounterMap<T> add(CounterMap<T> data)

  Description copied from interface: `Addable`
  adds this instance to the other given one and returns the result; this entry itself remains untouched

  Specified by:
    `add` in interface `Addable<CounterMap<T>>`

### getCountFor

    public int getCountFor(T element)

### getPercentageFor

    public double getPercentageFor(T element)

### getCountStatistics

    public DataPoint getCountStatistics()

### getMaxCount

    public int getMaxCount()

### getMinCount

    public int getMinCount()

### getTotal

    public int getTotal()

### getSortedElements

    public TreeSet<T> getSortedElements()

### getSortedElements

    public TreeSet<T> getSortedElements(Comparator<? super T> comp)

### getSortedElementsByCount

    public TreeSet<T> getSortedElementsByCount(boolean ascending)

### getElements

    public Set<T> getElements()

### size

    public int size()

### isEmpty

    public boolean isEmpty()

### getView

    public Map<T,Integer> getView()

  provides an unmodifiable view of the data

### getUniques

    public ArrayList<T> getUniques()

### getDublicates

    public ArrayList<T> getDublicates()

### clear

    public void clear()

### toDetailedString

    public String toDetailedString()

  Description copied from interface: `DetailedString`
  provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

  Specified by:
    `toDetailedString` in interface `DetailedString`
  Returns:
    a (potentially multi-line) String providing full details on this object instance

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

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