Accepts int, long, char or Comparable values. New values added must be comparable to those that have been added, otherwise the add method will throw an IllegalArgumentException.
Integer values (int, long, Integer, Long) are not distinguished by type --
i.e. addValue(Long.valueOf(2)), addValue(2), addValue(2l) all have
the same effect (similarly for arguments to getCount, etc.).
Note
byte and short values will be implicitly converted to int values by the compiler, thus there are no explicit overloaded methods for these primitive types.
char values are converted by addValue to Character instances.
As such, these values are not comparable to integral values, so attempts
to combine integral types with chars in a frequency distribution will fail.
Float is not coerced to Double. Since they are not Comparable with each other the user must do any necessary coercion. Float.NaN and Double.NaN are not treated specially; they may occur in input and will occur in output if appropriate.
The values are ordered using the default (natural order), unless a
Comparator is supplied in the constructor.
| Modifier and Type | Class and Description |
|---|---|
| private static class | Frequency.
the type of the objects compared T extends ComparableA Comparator that compares comparable objects using the natural order. |
| Modifier and Type | Field and Description |
|---|---|
| private final SortedMap | freqTable
underlying collection |
| private static final long | serialVersionUID
Serializable version identifier |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Frequency(Comparator<?>
Comparator used to order values comparator)Constructor allowing values Comparator to be specified. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addValue(Comparable<?>
the value to add. v)Adds 1 to the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added. |
| public void | |
| public void | |
| public void | |
| public void | |
| public Iterator | Returns: entry set IteratorReturn an Iterator over the set of keys and values that have been added. |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public long | Returns: the frequency of v.the value to lookup. v)Returns the number of values equal to v. Returns 0 if the value is not comparable. |
| public long | Returns: the frequency of v.the value to lookup. v)Returns the number of values equal to v. |
| public long | Returns: the frequency of v.the value to lookup. v)Returns the number of values equal to v. |
| public long | Returns: the frequency of v.the value to lookup. v)Returns the number of values equal to v. |
| public long | Returns: the proportion of values equal to vthe value to lookup. v)Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set. |
| public long | Returns: the proportion of values equal to vthe value to lookup v)Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set. |
| public long | Returns: the proportion of values equal to vthe value to lookup v)Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set. |
| public long | Returns: the proportion of values equal to vthe value to lookup v)Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set. |
| public double | Returns: the proportion of values less than or equal to vthe value to lookup v)Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values less than or equal to vthe value to lookup v)Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values less than or equal to vthe value to lookup v)Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values less than or equal to vthe value to lookup v)Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
| public List | Returns: a list containing the value(s) which appear most often.Returns the mode value(s) in comparator order. |
| public double | Returns: the proportion of values equal to vthe value to lookup v)Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values equal to vthe value to lookup v)Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values equal to vthe value to lookup v)Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
| public double | Returns: the proportion of values equal to vthe value to lookup v)Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
| public long | |
| public int | Returns: the number of unique values that have been added to the frequency table.Returns the number of values in the frequency table. |
| public int | |
| public void | incrementValue(Comparable<?>
the value to add. v, long the amount by which the value should be incremented increment)Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added. |
| public void | incrementValue(int
the value to add. v, long the amount by which the value should be incremented increment)Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added. |
| public void | incrementValue(long
the value to add. v, long the amount by which the value should be incremented increment)Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added. |
| public void | incrementValue(char
the value to add. v, long the amount by which the value should be incremented increment)Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added. |
| public void | |
| public void | merge(final Collection<Frequency>
the other others)Frequency objects to be mergedMerge a |
| public String | Returns: a string representation.Overrides java. Return a string representation of this frequency distribution. |
| public Iterator | Returns: values IteratorReturns an Iterator over the set of values that have been added. |
| freqTable | back to summary |
|---|---|
| private final SortedMap<Comparable<?>, Long> freqTable underlying collection | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| Frequency | back to summary |
|---|---|
| public Frequency() Default constructor. | |
| Frequency | back to summary |
|---|---|
| public Frequency(Comparator<?> comparator) Constructor allowing values Comparator to be specified.
| |
| addValue | back to summary |
|---|---|
| public void addValue(Comparable<?> v) throws MathIllegalArgumentException Adds 1 to the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
| |
| addValue | back to summary |
|---|---|
| public void addValue(int v) throws MathIllegalArgumentException Adds 1 to the frequency count for v.
| |
| addValue | back to summary |
|---|---|
| public void addValue(long v) throws MathIllegalArgumentException Adds 1 to the frequency count for v.
| |
| addValue | back to summary |
|---|---|
| public void addValue(char v) throws MathIllegalArgumentException Adds 1 to the frequency count for v.
| |
| clear | back to summary |
|---|---|
| public void clear() Clears the frequency table | |
| entrySetIterator | back to summary |
|---|---|
| public Iterator Return an Iterator over the set of keys and values that have been added. Using the entry set to iterate is more efficient in the case where you need to access respective counts as well as values, since it doesn't require a "get" for every key...the value is provided in the Map.Entry. If added values are integral (i.e., integers, longs, Integers, or Longs), they are converted to Longs when they are added, so the values of the map entries returned by the Iterator will in this case be Longs.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getCount | back to summary |
|---|---|
| public long getCount(Comparable<?> v) Returns the number of values equal to v. Returns 0 if the value is not comparable.
| |
| getCount | back to summary |
|---|---|
| public long getCount(int v) Returns the number of values equal to v.
| |
| getCount | back to summary |
|---|---|
| public long getCount(long v) Returns the number of values equal to v.
| |
| getCount | back to summary |
|---|---|
| public long getCount(char v) Returns the number of values equal to v.
| |
| getCumFreq | back to summary |
|---|---|
| public long getCumFreq(Comparable<?> v) Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set.
| |
| getCumFreq | back to summary |
|---|---|
| public long getCumFreq(int v) Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set.
| |
| getCumFreq | back to summary |
|---|---|
| public long getCumFreq(long v) Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set.
| |
| getCumFreq | back to summary |
|---|---|
| public long getCumFreq(char v) Returns the cumulative frequency of values less than or equal to v. Returns 0 if v is not comparable to the values set.
| |
| getCumPct | back to summary |
|---|---|
| public double getCumPct(Comparable<?> v) Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1).
Returns
| |
| getCumPct | back to summary |
|---|---|
| public double getCumPct(int v) Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). Returns 0 if v is not comparable to the values set.
| |
| getCumPct | back to summary |
|---|---|
| public double getCumPct(long v) Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). Returns 0 if v is not comparable to the values set.
| |
| getCumPct | back to summary |
|---|---|
| public double getCumPct(char v) Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). Returns 0 if v is not comparable to the values set.
| |
| getMode | back to summary |
|---|---|
| public List Returns the mode value(s) in comparator order.
| |
| getPct | back to summary |
|---|---|
| public double getPct(Comparable<?> v) Returns the percentage of values that are equal to v (as a proportion between 0 and 1).
Returns
| |
| getPct | back to summary |
|---|---|
| public double getPct(int v) Returns the percentage of values that are equal to v (as a proportion between 0 and 1).
| |
| getPct | back to summary |
|---|---|
| public double getPct(long v) Returns the percentage of values that are equal to v (as a proportion between 0 and 1).
| |
| getPct | back to summary |
|---|---|
| public double getPct(char v) Returns the percentage of values that are equal to v (as a proportion between 0 and 1).
| |
| getSumFreq | back to summary |
|---|---|
| public long getSumFreq() Returns the sum of all frequencies.
| |
| getUniqueCount | back to summary |
|---|---|
| public int getUniqueCount() Returns the number of values in the frequency table.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| incrementValue | back to summary |
|---|---|
| public void incrementValue(Comparable<?> v, long increment) throws MathIllegalArgumentException Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
| |
| incrementValue | back to summary |
|---|---|
| public void incrementValue(int v, long increment) throws MathIllegalArgumentException Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
| |
| incrementValue | back to summary |
|---|---|
| public void incrementValue(long v, long increment) throws MathIllegalArgumentException Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
| |
| incrementValue | back to summary |
|---|---|
| public void incrementValue(char v, long increment) throws MathIllegalArgumentException Increments the frequency count for v. If other objects have already been added to this Frequency, v must be comparable to those that have already been added.
| |
| merge | back to summary |
|---|---|
| public void merge(final Frequency other) throws NullArgumentException Merge another Frequency object's counts into this instance. This Frequency's counts will be incremented (or set when not already set) by the counts represented by other.
| |
| merge | back to summary |
|---|---|
| public void merge(final Collection<Frequency> others) throws NullArgumentException Merge a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return a string representation of this frequency distribution. | |
| valuesIterator | back to summary |
|---|---|
| public Iterator Returns an Iterator over the set of values that have been added. If added values are integral (i.e., integers, longs, Integers, or Longs), they are converted to Longs when they are added, so the objects returned by the Iterator will in this case be Longs.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Serializable version identifier |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: result of comparisonthe first object o1, Comparable<T> the second object o2)Implements java. Compare the two |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| NaturalComparator | back to summary |
|---|---|
| private NaturalComparator() | |
| compare | back to summary |
|---|---|
| public int compare(Comparable<T> o1, Comparable<T> o2) Implements java. Compare the two ((
| |