tl.lin.data.fd
Class Object2IntFrequencyDistributionEntry<K extends Comparable<K>>

java.lang.Object
  extended by tl.lin.data.fd.Object2IntFrequencyDistributionEntry<K>
All Implemented Interfaces:
Iterable<PairOfObjectInt<K>>, Object2IntFrequencyDistribution<K>, SortableEntries<PairOfObjectInt<K>>

public class Object2IntFrequencyDistributionEntry<K extends Comparable<K>>
extends Object
implements Object2IntFrequencyDistribution<K>

Implementation of Object2IntFrequencyDistribution based on HMapKI.


Nested Class Summary
 
Nested classes/interfaces inherited from interface tl.lin.data.SortableEntries
SortableEntries.Order
 
Constructor Summary
Object2IntFrequencyDistributionEntry()
           
 
Method Summary
 void clear()
          Removes all events.
 double computeLogRelativeFrequency(K k)
          Computes the log (base e) of the relative frequency of a particular event key.
 double computeRelativeFrequency(K k)
          Computes the relative frequency of a particular event key.
 boolean contains(K k)
          Returns true if key exists in this object.
 void decrement(K key)
          Decrements the count of an event key.
 void decrement(K key, int cnt)
          Decrements the count of a particular event key by cnt.
 int get(K k)
          Returns the count of a particular event key.
 List<PairOfObjectInt<K>> getEntries(SortableEntries.Order ordering)
           
 List<PairOfObjectInt<K>> getEntries(SortableEntries.Order ordering, int n)
           
 int getNumberOfEvents()
          Returns number of distinct events observed.
 long getSumOfCounts()
          Returns the sum of counts of all observed events.
 void increment(K key)
          Increments the count of an event key.
 void increment(K key, int cnt)
          Increments the count of an event key by cnt.
 Iterator<PairOfObjectInt<K>> iterator()
          Iterator returns the same object every time, just with a different payload.
 Set<K> keySet()
          Returns the set of keys.
 int remove(K k)
          Removes the count of a particular event key.
 int set(K k, int v)
          Sets the count of a particular event key to cnt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Object2IntFrequencyDistributionEntry

public Object2IntFrequencyDistributionEntry()
Method Detail

increment

public void increment(K key)
Description copied from interface: Object2IntFrequencyDistribution
Increments the count of an event key.

Specified by:
increment in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

increment

public void increment(K key,
                      int cnt)
Description copied from interface: Object2IntFrequencyDistribution
Increments the count of an event key by cnt.

Specified by:
increment in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

decrement

public void decrement(K key)
Description copied from interface: Object2IntFrequencyDistribution
Decrements the count of an event key.

Specified by:
decrement in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

decrement

public void decrement(K key,
                      int cnt)
Description copied from interface: Object2IntFrequencyDistribution
Decrements the count of a particular event key by cnt.

Specified by:
decrement in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

contains

public boolean contains(K k)
Description copied from interface: Object2IntFrequencyDistribution
Returns true if key exists in this object.

Specified by:
contains in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

get

public int get(K k)
Description copied from interface: Object2IntFrequencyDistribution
Returns the count of a particular event key.

Specified by:
get in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

set

public int set(K k,
               int v)
Description copied from interface: Object2IntFrequencyDistribution
Sets the count of a particular event key to cnt.

Specified by:
set in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

computeRelativeFrequency

public double computeRelativeFrequency(K k)
Description copied from interface: Object2IntFrequencyDistribution
Computes the relative frequency of a particular event key. That is, f(key) / SUM_i f(key_i).

Specified by:
computeRelativeFrequency in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

computeLogRelativeFrequency

public double computeLogRelativeFrequency(K k)
Description copied from interface: Object2IntFrequencyDistribution
Computes the log (base e) of the relative frequency of a particular event key.

Specified by:
computeLogRelativeFrequency in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

remove

public int remove(K k)
Description copied from interface: Object2IntFrequencyDistribution
Removes the count of a particular event key.

Specified by:
remove in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

clear

public void clear()
Description copied from interface: Object2IntFrequencyDistribution
Removes all events.

Specified by:
clear in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

getNumberOfEvents

public int getNumberOfEvents()
Description copied from interface: Object2IntFrequencyDistribution
Returns number of distinct events observed. Note that if an event is observed and then its count subsequently removed, the event will not be included in this count.

Specified by:
getNumberOfEvents in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

getSumOfCounts

public long getSumOfCounts()
Description copied from interface: Object2IntFrequencyDistribution
Returns the sum of counts of all observed events. That is, SUM_i f(key_i).

Specified by:
getSumOfCounts in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

keySet

public Set<K> keySet()
Description copied from interface: Object2IntFrequencyDistribution
Returns the set of keys.

Specified by:
keySet in interface Object2IntFrequencyDistribution<K extends Comparable<K>>

iterator

public Iterator<PairOfObjectInt<K>> iterator()
Iterator returns the same object every time, just with a different payload.

Specified by:
iterator in interface Iterable<PairOfObjectInt<K extends Comparable<K>>>

getEntries

public List<PairOfObjectInt<K>> getEntries(SortableEntries.Order ordering)
Specified by:
getEntries in interface SortableEntries<PairOfObjectInt<K extends Comparable<K>>>

getEntries

public List<PairOfObjectInt<K>> getEntries(SortableEntries.Order ordering,
                                           int n)
Specified by:
getEntries in interface SortableEntries<PairOfObjectInt<K extends Comparable<K>>>


Copyright © 2013. All Rights Reserved.