public class ValueFreq
extends java.lang.Object
this class store a value (String) and its frequency (int)
Modifier and Type | Field and Description |
---|---|
protected int |
Freq
Frequecy of the value.
|
protected java.lang.String |
Value
String value.
|
Constructor and Description |
---|
ValueFreq()
Creates a new instance of Pair Value-frequency
|
ValueFreq(java.lang.String newValue,
int newFreq)
Creates a new pair with established value and frequency
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Test it the provided object is equal in value to this object
Overrides Object.equals()
|
int |
getFreq()
Returns the frequency of this element
|
java.lang.String |
getValue()
Returns the value of this object (the string)
|
void |
incFreq()
Increases this object frequency by one
|
boolean |
moreFreq(ValueFreq ref)
Compares the frequencies of two pair, and test if this object's frequency is higher than the provided one
|
protected java.lang.String Value
protected int Freq
public ValueFreq()
Creates a new instance of Pair Value-frequency
public ValueFreq(java.lang.String newValue, int newFreq)
Creates a new pair with established value and frequency
newValue
- The value of the pairnewFreq
- The frequency associatedpublic boolean equals(java.lang.Object obj)
Test it the provided object is equal in value to this object Overrides Object.equals()
equals
in class java.lang.Object
public void incFreq()
Increases this object frequency by one
public boolean moreFreq(ValueFreq ref)
Compares the frequencies of two pair, and test if this object's frequency is higher than the provided one
ref
- The reference pairpublic java.lang.String getValue()
Returns the value of this object (the string)
public int getFreq()
Returns the frequency of this element