Next: Filtered and mapped views
Up: Advanced collection
Previous: Collectors
Index
In histogram.diesel:
A histogram supports accumulating counts for particular values and
then printing out the results in a reasonable fashion. Abstractly,
a histogram is a mapping from some domain of values to
integers. The increment operation bumps the count associated with
a particular value. To support the histogram's hash-table-based
implementation, the values being counted by the histogram must be
hashable. If the keys also are ordered, then nicer output is
possible. The methods new_unsorted_histogram
vs. new_histogram
construct the two kinds of histograms.
module Histogram;
class histogram[T <= hashable[T]] isa hash_CR_table[T,integer];
fun new_unsorted_histogram[T <= hashable[T]]():histogram[T];
fun new_unsorted_histogram[T <= hashable[T]](t:string):histogram[T];
fun increment(t:histogram[`T], x:T):void;
fun increment_by_count(t:histogram[`T], x:T, cnt:integer):void;
fun increment(t:histogram[`T], x:T, elem:any):void;
fun print_statistics(t:histogram[`T]):string;
fun print_statistics(t:histogram[`T], some_key:T|string):string;
fun ordered_keys(t:histogram[`T]):collection[T];
fun frequency_sorted_print_string(t:histogram[`T]):string;
fun percent_print_string(t:histogram[`T]):string;
fun truncated_percent_print_string(t:histogram[`T <= ordered[T]],
over:T):string;
fun unsorted_distribution[`T <= hashable[T]](
nm:string, cl:&(increment:&(value:T):void,
add_value:&(value:T, elem:any):void):void
):histogram[T];
class sorted_histogram[T <= ordered_hashable[T]] isa histogram[T];
fun new_histogram[T <= ordered_hashable[T]]():histogram[T];
fun new_histogram[T <= ordered_hashable[T]](t:string):histogram[T];
fun distribution[`T <= ordered_hashable[T]](
nm:string,
cl:&(increment:&(value:T):void,
add_value:&(value:T, elem:any):void):void
):histogram[T];
fun distribution(nm:string,
cl:&(increment:&(value:int):void,
add_value:&(value:int, elem:any):void):void
):histogram[int];
Next: Filtered and mapped views
Up: Advanced collection
Previous: Collectors
Index
Cecil/Vortex Project