me.edwards.des.demo
Class Counter

java.lang.Object
  extended by me.edwards.des.demo.Counter

public class Counter
extends java.lang.Object

Handles tabulation of a BlockChain into result data. The count method will walk the longest branch in the specified BlockChain and generate its results in a compact, easy to read form.

Created on: Dec 30, 2015 at 9:28:35 AM

Author:
Matthew Edwards

Nested Class Summary
static class Counter.Result
          Data structure representing one section of result data: The election vote ID (e.g.
 
Constructor Summary
Counter()
           
 
Method Summary
static java.util.ArrayList<Counter.Result> count(BlockChain bc)
          Tabulates the results from the longest branch in the specified BlockChain.
static java.lang.String toString(java.util.ArrayList<Counter.Result> results)
          Formats a list of results into a human-readable String.
static java.util.ArrayList<Counter.Result> trim(java.util.ArrayList<Counter.Result> toTrim)
          Trims the specified list of results to include only the winners (or the ties) of each respective election ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Method Detail

count

public static java.util.ArrayList<Counter.Result> count(BlockChain bc)
Tabulates the results from the longest branch in the specified BlockChain.

Parameters:
bc - BlockChain from which to tabulate the results
Returns:
The generated ArrayList of Results

trim

public static java.util.ArrayList<Counter.Result> trim(java.util.ArrayList<Counter.Result> toTrim)
Trims the specified list of results to include only the winners (or the ties) of each respective election ID.

Parameters:
toTrim - The results to trim
Returns:
An ArrayList containing the trimmed results

toString

public static java.lang.String toString(java.util.ArrayList<Counter.Result> results)
Formats a list of results into a human-readable String.

Parameters:
results - List of results to format
Returns:
List of results formatted as a human-readable String
See Also:
trim(ArrayList)