antsim
Class Stats

java.lang.Object
  |
  +--antsim.Stats
All Implemented Interfaces:
Clearable

public class Stats
extends Object
implements Clearable

The Stats class enables programmers to collect information about events occurring during a simulation. In particular, this class may be used to count the occurrence of events. Each event is identified by a string name chosen by the programmer and is associated to a counter. The value of the counter may be incremented by one by invoking method increment(); the same value may be read by invoking method get().

Version:
$Revision: 1.4 $
Author:
Alberto Montresor

Constructor Summary
Stats()
          Initializes an empty stats object.
 
Method Summary
 void add(String name, float addend)
          Add the value of addend to the counter identified by name.
 void clear()
          Restores the object to its initial state.
 void computeAvg()
          Computes the average of all the values stored in the map, and keeps the result in the avgMap.
 float get(String name)
          Return the value of the counter identified by name
static float getAvg(String name)
          Return the average value of the counter identified by name
 String headingToString()
          Returns a semi-colon separated list of headings to be printed
 void inc(String name)
          Increment by 1 the value of the counter identified by name.
 String toString()
          Returns a semi-colon separated list of values to be printed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stats

public Stats()
Initializes an empty stats object.

Method Detail

inc

public void inc(String name)
Increment by 1 the value of the counter identified by name.


add

public void add(String name,
                float addend)
Add the value of addend to the counter identified by name.


get

public float get(String name)
Return the value of the counter identified by name


getAvg

public static float getAvg(String name)
Return the average value of the counter identified by name


computeAvg

public void computeAvg()
Computes the average of all the values stored in the map, and keeps the result in the avgMap. The avgMap should not be cleared between iterations, therefore it is not inclued in this class' clear method.


headingToString

public String headingToString()
Returns a semi-colon separated list of headings to be printed


toString

public String toString()
Returns a semi-colon separated list of values to be printed

Overrides:
toString in class Object

clear

public void clear()
Restores the object to its initial state.

Specified by:
clear in interface Clearable