Class Counter

java.lang.Object
org.djutils.stats.summarizers.Counter
All Implemented Interfaces:
Serializable, Statistic
Direct Known Subclasses:
EventBasedCounter

public class Counter extends Object implements Statistic
The Counter class defines a statistics event counter.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.

Author:
Alexander Verbraeck, Peter Jacobs
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Counter(String description)
    Constructs a new Counter.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the current counter value.
    Returns the description of the statistic.
    long
    Return the current number of observations.
    void
    Initialize the counter.
    long
    register(long value)
    Process one observed value.
    static String
    Return a string representing a footer for a textual table with a monospaced font that can contain multiple statistics.
    static String
    Return a string representing a header for a textual table with a monospaced font that can contain multiple statistics.
    Return a string representing a line with important statistics values for this statistic, for a textual table with a monospaced font that can contain multiple statistics.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djutils.stats.summarizers.Statistic

    formatFixed
  • Constructor Details

    • Counter

      public Counter(String description)
      Constructs a new Counter.
      Parameters:
      description - String; the description for this counter
  • Method Details

    • getCount

      public long getCount()
      Returns the current counter value.
      Returns:
      long; the counter value
    • getN

      public long getN()
      Description copied from interface: Statistic
      Return the current number of observations.
      Specified by:
      getN in interface Statistic
      Returns:
      long; the number of observations
    • register

      public long register(long value)
      Process one observed value.
      Parameters:
      value - long; the value to process
      Returns:
      long; the value
    • initialize

      public void initialize()
      Initialize the counter.
      Specified by:
      initialize in interface Statistic
    • getDescription

      public String getDescription()
      Description copied from interface: Statistic
      Returns the description of the statistic.
      Specified by:
      getDescription in interface Statistic
      Returns:
      String; the description of the statistic
    • reportHeader

      public static String reportHeader()
      Return a string representing a header for a textual table with a monospaced font that can contain multiple statistics.
      Returns:
      String; header for the textual table.
    • reportLine

      public String reportLine()
      Description copied from interface: Statistic
      Return a string representing a line with important statistics values for this statistic, for a textual table with a monospaced font that can contain multiple statistics.
      Specified by:
      reportLine in interface Statistic
      Returns:
      String; line with most important values of the statistic
    • reportFooter

      public static String reportFooter()
      Return a string representing a footer for a textual table with a monospaced font that can contain multiple statistics.
      Returns:
      String; footer for the textual table
    • toString

      public String toString()
      Overrides:
      toString in class Object