|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.indiana.util.statistics.RunningVote
public class RunningVote
Maintains a running vote among double values. Ties are broken arbitrarily, according to iteration order of the Double objects within a HashMap. This class is particularly useful for tracking an aggregate value for a nominal variable.
Field Summary | |
---|---|
protected java.lang.Double |
majorityValue
The value of the current majority. |
protected double |
majorityVoteCount
The number of votes the majority value has received. |
protected double |
totalVoteCount
The total number of votes being tracked in this RunningVote object. |
protected java.util.HashMap |
votes
A mapping from a Double value to the number of votes (a MutableDouble) received for that value so far. |
Constructor Summary | |
---|---|
RunningVote()
|
|
RunningVote(java.util.HashMap votes)
|
Method Summary | |
---|---|
void |
add(double voteRecipient)
|
void |
add(double voteRecipient,
double voteAmount)
Add a vote for the given value. |
double |
calcAggregateValue()
|
protected void |
calcMajority()
|
boolean |
equals(java.lang.Object otherObj)
|
double |
getAgreeCount()
|
double |
getDisagreeCount()
|
double |
getMax()
|
double |
getMin()
|
int |
hashCode()
|
static void |
main(java.lang.String[] args)
A simple test method. |
void |
remove(double votesRemovedFrom)
Remove a vote for the given value. |
void |
remove(double votesRemovedFrom,
double amountToRemove)
Remove a vote for the given value. |
void |
reset()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap votes
protected java.lang.Double majorityValue
protected double majorityVoteCount
protected double totalVoteCount
Constructor Detail |
---|
public RunningVote()
public RunningVote(java.util.HashMap votes)
Method Detail |
---|
protected void calcMajority()
public void add(double voteRecipient)
add
in interface RunningAggregate
public void add(double voteRecipient, double voteAmount)
public void remove(double votesRemovedFrom)
remove
in interface RunningAggregate
public void remove(double votesRemovedFrom, double amountToRemove)
public double calcAggregateValue()
calcAggregateValue
in interface RunningAggregate
public double getAgreeCount()
public double getDisagreeCount()
public void reset()
reset
in interface RunningAggregate
public boolean equals(java.lang.Object otherObj)
equals
in interface RunningAggregate
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface RunningAggregate
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
public double getMax()
getMax
in interface RunningAggregate
public double getMin()
getMin
in interface RunningAggregate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |