module ReportStat: sig
.. end
This module defines the types and functions related to statistics.
All operations gracefully handle overflows by ensuring that:
- a value above
max_int
is encoded by max_int
;
- a value below
min_int
is encoded by min_int
.
type
single = {
|
mutable count :int ; |
|
mutable total :int ; |
}
The type of statistics for a single point kind.
type
all = (Common.point_kind * single) list
The type of statistics for all point kinds, encoded as an association
list containing all points kinds in ascending order.
val make : unit -> all
Returns empty statistics for all point kinds.
All elements have both count
and total
set to zero.
val update : all -> Common.point_kind -> bool -> unit
update stats k b
updates stats
for point kind k
.
total
is always incremented, while count
is incremented
iff b
equals true
.
val summarize : all -> int * int
Returns a (count, total)
couple where count
and total
are
the sums of respectively all count
and all total
fields from
the passed statistics.
val add : all -> all -> all
add x y
returns the sum of statistics x
and y
.
val sum : all list -> all
sum l
is a fold over l
elements with function add
,
using the value returned by make
as the initial value.