Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.common.statistic
Class SimpleStatistics<T extends Number>

    java.lang.Object
      org.modeshape.common.statistic.SimpleStatistics<T>

Type Parameters:
  `T` - the number type used in these statistics

Direct Known Subclasses:
  DetailedStatistics

    @ThreadSafe
    public class SimpleStatistics<T extends Number>

extends Object

Encapsulation of the statistics for a series of values to which new values are frequently added. The statistics include the `minimum`, `maximum`, `total (aggregate sum)`, and `mean (average)`. See `DetailedStatistics` for a subclass that also calculates the `median`, `standard deviation` and the `histogram` of the values.

This class is threadsafe.

Field Summary
`protected MathOperations<T>` | `math`

Constructor Summary
`SimpleStatistics(MathOperations<T> operations)`

Method Summary
`void` | `add(T value)` Add a new value to these statistics.
`protected void` | `doAddValue(T value)` A method that can be overridden by subclasses when `add` is called.
`protected void` | `doReset()` Method that can be overridden by subclasses when `reset()` is called.
`int` | `getCount()` Get the number of values that have been measured.
`protected ReadWriteLock` | `getLock()`
`MathOperations<T>` | `getMathOperations()`
`T` | `getMaximum()` Get the maximum value in the series.
`T` | `getMean()` Return the approximate mean (average) value represented as an instance of the operand type.
`double` | `getMeanValue()` Return the mean (average) value.
`T` | `getMinimum()` Get the minimum value in the series.
`T` | `getTotal()` Get the aggregate sum of the values in the series.
`void` | `reset()` Reset the statistics in this object, and clear out any stored information.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### math

    protected final MathOperations<T extends Number> math

Constructor Detail

### SimpleStatistics

    public SimpleStatistics(MathOperations<T> operations)

Method Detail

### add

    public void add(T value)

  Add a new value to these statistics.

  Parameters:
    `value` - the new value

### doAddValue

    protected void doAddValue(T value)

  A method that can be overridden by subclasses when `add` is called. This method is called within the write lock, and does real work. Therefore, subclasses should call this method when they overwrite it.

  Parameters:
    `value` - the value already added

### getTotal

    public T getTotal()

  Get the aggregate sum of the values in the series.

  Returns:
    the total of the values, or 0.0 if the `count` is 0

### getMaximum

    public T getMaximum()

  Get the maximum value in the series.

  Returns:
    the maximum value, or 0.0 if the `count` is 0

### getMinimum

    public T getMinimum()

  Get the minimum value in the series.

  Returns:
    the minimum value, or 0.0 if the `count` is 0

### getCount

    public int getCount()

  Get the number of values that have been measured.

  Returns:
    the count

### getMean

    public T getMean()

  Return the approximate mean (average) value represented as an instance of the operand type. Note that this may truncate if the operand type is not able to have the required precision. For the accurate mean, see `getMeanValue()`.

  Returns:
    the mean (average), or 0.0 if the `count` is 0

### getMeanValue

    public double getMeanValue()

  Return the mean (average) value.

  Returns:
    the mean (average), or 0.0 if the `count` is 0
  See Also:
    `getMean()`

### reset

    public void reset()

  Reset the statistics in this object, and clear out any stored information.

### getMathOperations

    public MathOperations<T> getMathOperations()

### getLock

    protected ReadWriteLock getLock()

### doReset

    protected void doReset()

  Method that can be overridden by subclasses when `reset()` is called. This method is called while the object is locked for write and does work; therefore, the subclass should call this method.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.