|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeersim.util.IncrementalFreq
public class IncrementalFreq
A class that can collect frequency information on integer input. right now it can handle only unsigned input. It simply ignores negative numbers.
Constructor Summary | |
---|---|
IncrementalFreq()
Calls this(-1) , that is, no values will be ignored. |
|
IncrementalFreq(int maxvalue)
|
Method Summary | |
---|---|
void |
add(int i)
Adds item i to the input set. |
void |
add(int i,
int k)
Adds item i to the input set k times. |
java.lang.Object |
clone()
|
boolean |
equals(java.lang.Object obj)
Tests equality between two IncrementalFreq instances. |
int |
getFreq(int i)
Returns the number of occurrences of the given integer. |
int |
getN()
Returns number of processed data items. |
int |
hashCode()
Hashcode (consistent with equals(java.lang.Object) ). |
void |
print(java.io.PrintStream out)
Prints current frequency information. |
void |
printAll(java.io.PrintStream out)
Prints current frequency information. |
void |
remove(IncrementalFreq other,
boolean strict)
Performs an element-by-element vector subtraction of the frequency vectors. |
void |
reset()
Reset the state of the object. |
java.lang.String |
toArithmeticExpression()
An alternative method to convert the object to String |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IncrementalFreq(int maxvalue)
maxvalue
- Values in the input set larger than this one will be ignored.
However, if it is negative, no values are ignored.public IncrementalFreq()
this(-1)
, that is, no values will be ignored.
IncrementalFreq(int)
Method Detail |
---|
public void reset()
public final void add(int i)
i
to the input set.
It calls add(i,1)
.
add(int,int)
public void add(int i, int k)
i
to the input set k
times.
That is, it increments counter i
by k
.
If, however, i
is negative, or larger than the maximum defined
at construction time (if a maximum was set at all) the operation is ignored.
public int getN()
public int getFreq(int i)
public void remove(IncrementalFreq other, boolean strict)
strict
is true, it
throws an IllegalArgumentException if this
is
not strictly larger than other
(element by element)
(Note that both frequency vectors are positive.)
Otherwise just sets those elements in this
to zero
that are smaller than those of other
.
other
- The instance of IncrementalFreq to subtractstrict
- See above explanationpublic void printAll(java.io.PrintStream out)
value occurrencesThat is, numbers with zero occurrences will also be printed.
public void print(java.io.PrintStream out)
value occurrences
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toArithmeticExpression()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
equals(java.lang.Object)
). Probably you will never want to
use this, but since we have equals(java.lang.Object)
, we must implement it.
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |