Class MutableDouble

java.lang.Object
org.djutils.base.MutableDouble

public class MutableDouble extends Object
A simple version of a mutable double with get() and set(double) functions.

Copyright (c) 2023-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck
  • Constructor Summary

    Constructors
    Constructor
    Description
    MutableDouble(double value)
    Initialize the mutable double with a value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dec()
    Decrement the modifiable double with 1.
    void
    dec(double decrement)
    Decrement the modifiable double with a value.
    void
    div(double divisor)
    Divide the modifiable double by a value.
    boolean
     
    double
    get()
     
    int
     
    void
    inc()
    Increment the modifiable double with 1.
    void
    inc(double increment)
    Increment the modifiable double with a value.
    void
    mul(double multiplier)
    Increment the modifiable double with a value.
    void
    set(double newValue)
    set the mutable double to a new value.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MutableDouble

      public MutableDouble(double value)
      Initialize the mutable double with a value.
      Parameters:
      value - double; the initial value of the mutable double
  • Method Details

    • set

      public void set(double newValue)
      set the mutable double to a new value.
      Parameters:
      newValue - double; the new value of the mutable double
    • get

      public double get()
      Returns:
      double; the current value of the mutable double
    • inc

      public void inc(double increment)
      Increment the modifiable double with a value.
      Parameters:
      increment - double; the value to increment the modifiable double with
    • inc

      public void inc()
      Increment the modifiable double with 1.
    • dec

      public void dec(double decrement)
      Decrement the modifiable double with a value.
      Parameters:
      decrement - double; the value to decrement the modifiable double with
    • dec

      public void dec()
      Decrement the modifiable double with 1.
    • mul

      public void mul(double multiplier)
      Increment the modifiable double with a value.
      Parameters:
      multiplier - double; the value to multiply the modifiable double with
    • div

      public void div(double divisor)
      Divide the modifiable double by a value.
      Parameters:
      divisor - double; the value to divide the modifiable double by
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object