com.quadrique.jbuildingblocks.core.dataStructure
Class JbbHistogram<V>
java.lang.Object
com.quadrique.jbuildingblocks.core.dataStructure.JbbHistogram<V>
- Type Parameters:
V - the datatype for the Values
public class JbbHistogram<V>
- extends Object
The histogram of a given set of input values is a list of buckets where
each bucket contains one of the input values and its associated number of occurences in the set.
For instance:
Histogram<Integer> histogram = new Histogram<Integer>();
histogram.add(1);
histogram.add(2);
histogram.add(3);
histogram.add(2);
histogram.add(2);
System.out.println("The number of buckets is: " + histogram.getNbOfBuckets());
ArrayList> list = histogram.getAllBuckets();
System.out.println("The buckets are: ");
for (HistogramBucket b : list)
{
System.out.println(b);
}
The corresponding execution results are:
The number of buckets is: 3
The buckets are:
Value: "2", Number of occurences: 3
Value: "1", Number of occurences: 1
Value: "3", Number of occurences: 1
JbbHistogram
public JbbHistogram()
add
public void add(V value)
- Parameters:
value -
getNbOfBuckets
public int getNbOfBuckets()
- Returns:
- number of buckets
getAllBuckets
public ArrayList<JbbHistogramBucket<V>> getAllBuckets()
throws Exception
- Returns:
- list
- Throws:
Exception
Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.