edu.umd.cloud9.util.count
Class OpenObject2IntFrequencyDistribution<K extends Comparable<K>>

java.lang.Object
  extended by edu.umd.cloud9.util.count.OpenObject2IntFrequencyDistribution<K>
All Implemented Interfaces:
Object2IntFrequencyDistribution<K>, Iterable<PairOfObjectInt<K>>

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

Implementation of Object2IntFrequencyDistribution based on Object2IntOpenHashMap.

Author:
Jimmy Lin

Constructor Summary
OpenObject2IntFrequencyDistribution()
           
 
Method Summary
 void clear()
          Removes all events.
 boolean contains(K k)
          Returns true if key exists in this object.
 void decrement(K key)
          Decrements the frequency of an event key.
 void decrement(K key, int cnt)
          Decrements the frequency of a particular event key by cnt.
 Object2IntMap.FastEntrySet<K> entrySet()
          Exposes efficient method for accessing mappings in this map.
 int get(K k)
          Returns the frequency of a particular event key.
 List<PairOfObjectInt<K>> getFrequencySortedEvents()
          Returns events sorted by frequency of occurrence.
 List<PairOfObjectInt<K>> getFrequencySortedEvents(int n)
          Returns top n events sorted by frequency of occurrence.
 int getNumberOfEvents()
          Returns number of distinct events observed.
 List<PairOfObjectInt<K>> getSortedEvents()
          Returns events in sorted order.
 List<PairOfObjectInt<K>> getSortedEvents(int n)
          Returns top n events in sorted order.
 long getSumOfFrequencies()
          Returns the sum of frequencies of all observed events.
 void increment(K key)
          Increments the frequency of an event key.
 void increment(K key, int cnt)
          Increments the frequency of an event key by cnt.
 Iterator<PairOfObjectInt<K>> iterator()
          Iterator returns the same object every time, just with a different payload.
 ObjectSet<K> keySet()
          Exposes efficient method for accessing keys in this map.
 int remove(K k)
          Removes the count of a particular event key.
 int set(K k, int v)
          Sets the frequency of a particular event key to cnt.
 IntCollection values()
          Exposes efficient method for accessing values in this map.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenObject2IntFrequencyDistribution

public OpenObject2IntFrequencyDistribution()
Method Detail

increment

public void increment(K key)
Description copied from interface: Object2IntFrequencyDistribution
Increments the frequency 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 frequency 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 frequency 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 frequency 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 frequency 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 frequency of a particular event key to cnt.

Specified by:
set 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>>

keySet

public ObjectSet<K> keySet()
Exposes efficient method for accessing keys in this map.


values

public IntCollection values()
Exposes efficient method for accessing values in this map.


entrySet

public Object2IntMap.FastEntrySet<K> entrySet()
Exposes efficient method for accessing mappings in this map.


getFrequencySortedEvents

public List<PairOfObjectInt<K>> getFrequencySortedEvents()
Description copied from interface: Object2IntFrequencyDistribution
Returns events sorted by frequency of occurrence.

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

getFrequencySortedEvents

public List<PairOfObjectInt<K>> getFrequencySortedEvents(int n)
Description copied from interface: Object2IntFrequencyDistribution
Returns top n events sorted by frequency of occurrence.

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

getSortedEvents

public List<PairOfObjectInt<K>> getSortedEvents()
Description copied from interface: Object2IntFrequencyDistribution
Returns events in sorted order.

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

getSortedEvents

public List<PairOfObjectInt<K>> getSortedEvents(int n)
Description copied from interface: Object2IntFrequencyDistribution
Returns top n events in sorted order.

Specified by:
getSortedEvents 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>>

getSumOfFrequencies

public long getSumOfFrequencies()
Description copied from interface: Object2IntFrequencyDistribution
Returns the sum of frequencies of all observed events.

Specified by:
getSumOfFrequencies 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>>>