Package hep.aida.bin

Class AbstractBin

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    AbstractBin1D

    public abstract class AbstractBin
    extends PersistentObject
    Abstract base class for all arbitrary-dimensional bins consumes double elements. First see the package summary and javadoc tree view to get the broad picture.

    This class is fully thread safe (all public methods are synchronized). Thus, you can have one or more threads adding to the bin as well as one or more threads reading and viewing the statistics of the bin while it is filled. For high performance, add data in large chunks (buffers) via method addAllOf rather than piecewise via method add.

    Version:
    0.9, 03-Jul-99
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractBin()
      Makes this class non instantiable, but still let's others inherit from it.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      double center()
      Returns center(0).
      double center​(int dimension)
      Returns a custom definable "center" measure; override this method if necessary.
      abstract void clear()
      Removes all elements from the receiver.
      boolean equals​(java.lang.Object otherObj)
      Returns whether two objects are equal; This default implementation returns true if the other object is a bin and has the same size, value, error and center.
      double error()
      Returns error(0).
      double error​(int dimension)
      Returns a custom definable error measure; override this method if necessary.
      abstract boolean isRebinnable()
      Returns whether a client can obtain all elements added to the receiver.
      double offset()
      Returns offset(0).
      double offset​(int dimension)
      Returns the relative or absolute position for the center of the bin; override this method if necessary.
      abstract int size()
      Returns the number of elements contained.
      java.lang.String toString()
      Returns a String representation of the receiver.
      void trimToSize()
      Trims the capacity of the receiver to be the receiver's current size.
      double value()
      Returns value(0).
      double value​(int dimension)
      Returns a custom definable "value" measure; override this method if necessary.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractBin

        protected AbstractBin()
        Makes this class non instantiable, but still let's others inherit from it.
    • Method Detail

      • center

        public final double center()
        Returns center(0).
      • center

        public double center​(int dimension)
        Returns a custom definable "center" measure; override this method if necessary. Returns the absolute or relative center of this bin. For example, the center of gravity. The real absolute center can be obtained as follow: partition(i).min(j) * bin(j).offset() + bin(j).center(i), where i is the dimension. and j is the index of this bin.

        This default implementation always returns 0.5.

        Parameters:
        dimension - the dimension to be considered (zero based).
      • clear

        public abstract void clear()
        Removes all elements from the receiver. The receiver will be empty after this call returns.
      • equals

        public boolean equals​(java.lang.Object otherObj)
        Returns whether two objects are equal; This default implementation returns true if the other object is a bin and has the same size, value, error and center.
        Overrides:
        equals in class java.lang.Object
      • error

        public final double error()
        Returns error(0).
      • error

        public double error​(int dimension)
        Returns a custom definable error measure; override this method if necessary. This default implementation always returns 0.
        Parameters:
        dimension - the dimension to be considered.
      • isRebinnable

        public abstract boolean isRebinnable()
        Returns whether a client can obtain all elements added to the receiver. In other words, tells whether the receiver internally preserves all added elements. If the receiver is rebinnable, the elements can be obtained via elements() methods.
      • offset

        public final double offset()
        Returns offset(0).
      • offset

        public double offset​(int dimension)
        Returns the relative or absolute position for the center of the bin; override this method if necessary. Returns 1.0 if a relative center is stored in the bin. Returns 0.0 if an absolute center is stored in the bin.

        This default implementation always returns 1.0 (relative).

        Parameters:
        dimension - the index of the considered dimension (zero based);
      • size

        public abstract int size()
        Returns the number of elements contained.
      • toString

        public java.lang.String toString()
        Returns a String representation of the receiver.
        Overrides:
        toString in class java.lang.Object
      • trimToSize

        public void trimToSize()
        Trims the capacity of the receiver to be the receiver's current size. Releases any superfluos internal memory. An application can use this operation to minimize the storage of the receiver. This default implementation does nothing.
      • value

        public final double value()
        Returns value(0).
      • value

        public double value​(int dimension)
        Returns a custom definable "value" measure; override this method if necessary.

        This default implementation always returns 0.0.

        Parameters:
        dimension - the dimension to be considered.