edu.umd.cloud9.util.count
Class OpenInt2LongFrequencyDistribution

java.lang.Object
  extended by edu.umd.cloud9.util.count.OpenInt2LongFrequencyDistribution
All Implemented Interfaces:
Int2LongFrequencyDistribution, Iterable<PairOfIntLong>

public class OpenInt2LongFrequencyDistribution
extends Object
implements Int2LongFrequencyDistribution

Implementation of Int2LongFrequencyDistribution based on Int2LongOpenHashMap.

Author:
Jimmy Lin

Constructor Summary
OpenInt2LongFrequencyDistribution()
           
 
Method Summary
 void clear()
          Removes all events.
 boolean contains(int key)
          Returns true if key exists in this object.
 void decrement(int key)
          Decrements the frequency of an event key.
 void decrement(int key, long cnt)
          Decrements the frequency of a particular event key by cnt.
 Int2LongMap.FastEntrySet entrySet()
          Exposes efficient method for accessing mappings in this map.
 long get(int key)
          Returns the frequency of a particular event key.
 List<PairOfIntLong> getFrequencySortedEvents()
          Returns events sorted by frequency of occurrence.
 List<PairOfIntLong> getFrequencySortedEvents(int n)
          Returns top n events sorted by frequency of occurrence.
 int getNumberOfEvents()
          Returns number of distinct events observed.
 List<PairOfIntLong> getSortedEvents()
          Returns events in sorted order.
 List<PairOfIntLong> getSortedEvents(int n)
          Returns top n events in sorted order.
 long getSumOfFrequencies()
          Returns the sum of frequencies of all observed events.
 void increment(int key)
          Increments the frequency of an event key.
 void increment(int key, long cnt)
          Increments the frequency of an event key by cnt.
 Iterator<PairOfIntLong> iterator()
          Iterator returns the same object every time, just with a different payload.
 IntSet keySet()
          Exposes efficient method for accessing keys in this map.
 long remove(int k)
          Removes the count of a particular event key.
 long set(int k, long v)
          Sets the frequency of a particular event key to cnt.
 LongCollection 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

OpenInt2LongFrequencyDistribution

public OpenInt2LongFrequencyDistribution()
Method Detail

increment

public void increment(int key)
Description copied from interface: Int2LongFrequencyDistribution
Increments the frequency of an event key.

Specified by:
increment in interface Int2LongFrequencyDistribution

increment

public void increment(int key,
                      long cnt)
Description copied from interface: Int2LongFrequencyDistribution
Increments the frequency of an event key by cnt.

Specified by:
increment in interface Int2LongFrequencyDistribution

decrement

public void decrement(int key)
Description copied from interface: Int2LongFrequencyDistribution
Decrements the frequency of an event key.

Specified by:
decrement in interface Int2LongFrequencyDistribution

decrement

public void decrement(int key,
                      long cnt)
Description copied from interface: Int2LongFrequencyDistribution
Decrements the frequency of a particular event key by cnt.

Specified by:
decrement in interface Int2LongFrequencyDistribution

contains

public boolean contains(int key)
Description copied from interface: Int2LongFrequencyDistribution
Returns true if key exists in this object.

Specified by:
contains in interface Int2LongFrequencyDistribution

get

public long get(int key)
Description copied from interface: Int2LongFrequencyDistribution
Returns the frequency of a particular event key.

Specified by:
get in interface Int2LongFrequencyDistribution

set

public long set(int k,
                long v)
Description copied from interface: Int2LongFrequencyDistribution
Sets the frequency of a particular event key to cnt.

Specified by:
set in interface Int2LongFrequencyDistribution

remove

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

Specified by:
remove in interface Int2LongFrequencyDistribution

clear

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

Specified by:
clear in interface Int2LongFrequencyDistribution

keySet

public IntSet keySet()
Exposes efficient method for accessing keys in this map.


values

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


entrySet

public Int2LongMap.FastEntrySet entrySet()
Exposes efficient method for accessing mappings in this map.


getFrequencySortedEvents

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

Specified by:
getFrequencySortedEvents in interface Int2LongFrequencyDistribution

getFrequencySortedEvents

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

Specified by:
getFrequencySortedEvents in interface Int2LongFrequencyDistribution

getSortedEvents

public List<PairOfIntLong> getSortedEvents()
Description copied from interface: Int2LongFrequencyDistribution
Returns events in sorted order.

Specified by:
getSortedEvents in interface Int2LongFrequencyDistribution

getSortedEvents

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

Specified by:
getSortedEvents in interface Int2LongFrequencyDistribution

getNumberOfEvents

public int getNumberOfEvents()
Description copied from interface: Int2LongFrequencyDistribution
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 Int2LongFrequencyDistribution

getSumOfFrequencies

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

Specified by:
getSumOfFrequencies in interface Int2LongFrequencyDistribution

iterator

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

Specified by:
iterator in interface Iterable<PairOfIntLong>