Class Distribution.FrequencyAndObject<O>

  • Type Parameters:
    O - Type of the object returned by the draw method
    All Implemented Interfaces:
    Serializable
    Enclosing class:
    Distribution<O>

    public static class Distribution.FrequencyAndObject<O>
    extends Object
    implements Serializable
    Immutable storage for a frequency (or probability) plus a Generator.

    Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
    All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version Mar 1, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers
    See Also:
    Serialized Form
    • Constructor Detail

      • FrequencyAndObject

        public FrequencyAndObject​(double frequency,
                                  O object)
        Construct a new FrequencyAndObject instance.
        Parameters:
        frequency - double; the (not cumulative) frequency (or probability) of the generatingObject
        object - O; an object
    • Method Detail

      • getFrequency

        public final double getFrequency()
        Retrieve the frequency (or probability) of this FrequencyAndObject.
        Returns:
        double; the frequency (or probability) of this FrequencyAndObject
      • getObject

        public final O getObject()
        Call the draw method of the generatingObject and return its result.
        Returns:
        O; the result of a call to the draw method of the generatingObject
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object