Class MutableFloat

java.lang.Object
org.djutils.base.MutableFloat

public class MutableFloat extends Object
A simple version of a mutable float with get() and set(float) 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
    MutableFloat(float value)
    Initialize the mutable float with a value.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • MutableFloat

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

    • set

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

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

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

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

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

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

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

      public void div(float divisor)
      Divide the modifiable float by a value.
      Parameters:
      divisor - float; the value to divide the modifiable float 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