|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbcds.tools.FreqTable<E>
public class FreqTable<E>
Implements a simple frequency table of elements of the parameterized
type E.
This is a simple frequency builder; there is no support for
classes, or lower/upper outliers, for example.
| Constructor Summary | |
|---|---|
FreqTable()
Default constructor. |
|
| Method Summary | ||
|---|---|---|
void |
clear()
Resets the table. |
|
boolean |
contains(E e)
Returns true if element e exists in the table. |
|
int |
getCount(E e)
Returns the frequency (or counter) of the element e, or
zero if that element does not exist. |
|
java.util.Collection<java.lang.Integer> |
getCounters()
Returns an list containing the frequency of each element, in no particular order. |
|
long |
getTotal()
Returns the number of occurrences registered in the table (not the number of elements), that is, the sum of the frequencies of all the elements in the table. |
|
void |
inc(E e)
Calls incr(e, 1). |
|
void |
inc(E e,
int incr)
Performs the equivalent of T[ e] += incr. |
|
java.util.Set<E> |
keySet()
Returns the elements in the table. |
|
static
|
make()
Syntactic sugar. |
|
void |
remove(E e)
Removes the element e. |
|
java.util.List<E> |
sortedByCounter()
Returns a new list containing the elements of the table, sorted by their frequency in ascending order. |
|
java.util.List<E> |
sortedByCounterDesc()
Returns a new list containing the elements of the table, sorted by their frequency in descending order. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FreqTable()
| Method Detail |
|---|
public static <E> FreqTable<E> make()
public void inc(E e,
int incr)
e] += incr.
e - the element whose frequency will be incremented. If it does
not exist, it is inserted with intial count set to incr.incr - the increment. It can be any value, including negatives.
No check is performed to guarantee that the frequency
remains positive.public void inc(E e)
public long getTotal()
public int getCount(E e)
e, or
zero if that element does not exist.
public boolean contains(E e)
e exists in the table.
public void clear()
public java.util.Collection<java.lang.Integer> getCounters()
public java.util.List<E> sortedByCounter()
public java.util.List<E> sortedByCounterDesc()
public java.util.Set<E> keySet()
public void remove(E e)
e. It does nothing if the element
does not exist.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||